<template>
    <div style="height: 100%; width: 100%; position: relative">
        <div class="pagetop">
            <div style="width: 100%">
                <div style="width: 100%; float: left">
                    <table style="font-size: 14px; width: 100%; border-spacing: 0px; white-space: nowrap" border="0" class="mytableclass">
                        <tr>
                            <td colspan="6">
                                <table style="font-size: 14px; width: 100%" border="0">
                                    <tr>
                                        <td style="width: 160px; padding-left: 10px">签收人：{{ recieveuser }}</td>
                                        <td style="width: 220px;">
                                            <div :title="performdept" style="width: 196px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap;text-align:left;">
                                                可签收科室：{{ performdept }}
                                            </div>
                                        </td>
                                        <td style="width: 200px">
                                            <div :title="allowrecievetype" style="width: 196px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap;text-align:left;">
                                                {{ allowrecievetype }}
                                            </div>
                                        </td>
                                        <td align="left" style="width: 280px">
                                            <el-select v-model="radioPrintWays" style="width: 120px" @change="PrintWaysChange">
                                                <el-option v-for="item in radioPrintWaysOption" :value="item.value" :key="item.value" :label="item.label"> </el-option>
                                            </el-select>

                                            <el-select v-model="chkprint" style="width: 120px" @change="ChkPrintChange">
                                                <el-option v-for="item in chkprintOption" :value="item.value" :key="item.value" :label="item.label"> </el-option>
                                            </el-select>
                                        </td>
                                        <td align="right" style="width: 70px">运送人：</td>
                                        <td>
                                            <rm-ddl-common style="display: inline-block" @change="userinfochange" datatype="userinfo" dataname="用户" v-model="userinfoval" width="160px" key="userno" :onlyshow="sendusercheckout == '1'" :readonly="sendusercheckout != '2'" :filterable="sendusercheckout == '2'" :clearable="sendusercheckout == '2'" @blur="userinfoblur"></rm-ddl-common>
                                            <el-button v-if="sendusercheckout == '1'" @click="loginUser()">登陆</el-button>
                                        </td>
                                        <td v-if="!isshow">
                                            <!-- <el-switch v-model="isasync" active-text="后台签收" inactive-text="立即签收"></el-switch> -->
                                            <el-checkbox v-model="isasync">快速扫描模式</el-checkbox>
                                            <el-checkbox v-model="isEasyMode" @change="EasyModeChange()" true-label='1' false-label="0">简易扫描模式&nbsp;&nbsp;&nbsp;&nbsp;</el-checkbox>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td width="80px" align="right" style="font-weight: bold; font-size: 17px">条码号：</td>
                            <td align="left">
                                <input value="" clearable :placeholder="barcodeholder" class="el-input__inner" autocomplete="off" @keydown.enter="scanBarcode('1', $event)" style="width: 465px; height: 36px" ref="barcode" id="barcodediv" @focus="HightlightPos()" />
                            </td>
                            <td align="right">
                                <div class="top-deal">
                                    <el-button icon="el-icon-close" @click="cancelbarcode()">取消签收</el-button>
                                    <el-button icon="el-icon-back" @click="Rejet()">标本退回</el-button>
                                    <el-button icon="el-icon-edit-outline" @click="btnSign()">护工签名</el-button>
                                    <el-button icon="el-icon-printer" @click="btnLabelPrint()">标签打印</el-button>
                                    <el-button icon="el-icon-printer" @click="btnPrint($event)">清单打印</el-button>
                                    <el-button icon="el-icon-circle-close" @click="btnClear()">清除</el-button>
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
        <div class="pagecenter">
            <div v-if="isEasyMode =='1'" style="height: 100%; width: 100%;">
                <div style="height: 35px; margin-bottom: 15px;">
                    <span style="font-size: 30px;">当前条码信息：</span>
                </div>
                <div>
                    <table style="font-size: 25px; width: 900px; border-spacing:1px 5px;">
                        <tr style="width: 100%;">
                            <td style="float: right; width: 125px;">
                                分单类别：
                            </td>
                            <td v-bind:style="{
                                            background: $pub.ColorChange(easyData.tube_color),
                                            color: $pub.colorConvert(easyData.tube_color),
                                        }" style="width: 400px;">
                                {{ easyData.req_groupna }}
                            </td>
                            <td style="float: right;">
                                加急：
                            </td>
                            <td v-bind:style="{
                                            color: easyData.emer_flag == '1'? 'red':'black',
                                        }" style="width: 245px;">
                                {{ easyData.emer_flag == '1' ? '急':''}}
                            </td>
                        </tr>
                        <tr>
                            <td style="float: right;">
                                标本类型：
                            </td>
                            <td>
                                {{easyData.specimen_name}}
                            </td>
                            <td style="float: right;">
                                病人号：
                            </td>
                            <td>
                                {{easyData.pat_no}}
                            </td>
                        </tr>
                        <tr>
                            <td style="float: right;">
                                条码号：
                            </td>
                            <td>
                                {{easyData.barcode}}
                            </td>
                            <td style="float: right;">
                                病区：
                            </td>
                            <td>
                                {{easyData.req_wardname}}
                            </td>
                        </tr>
                        <tr>
                            <td style="float: right;">
                                申请科室：
                            </td>
                            <td>
                                {{easyData.req_deptname}}
                            </td>
                            <td style="float: right;">
                                床号：
                            </td>
                            <td>
                                {{easyData.req_bedno}}
                            </td>
                        </tr>
                        <tr>
                            <td style="float: right;">
                                申请状态：
                            </td>
                            <td>
                                {{easyData.req_statname}}
                            </td>
                            <td style="float: right;">
                                姓名：
                            </td>
                            <td>
                                {{easyData.pat_name}}
                            </td>
                        </tr>
                        <tr>
                            <td style="float: right;">
                                项目描述：
                            </td>
                            <td>
                                {{easyData.sample_items}}
                            </td>
                            <td style="float: right;">
                                性别：
                            </td>
                            <td>
                                {{easyData.pat_sexname}}
                            </td>
                        </tr>
                        <tr>
                            <td style="float: right;">
                                采样时间：
                            </td>
                            <td>
                                {{easyData.sampled_dt}}
                            </td>
                            <td style="float: right;">
                                年龄：
                            </td>
                            <td>
                                {{easyData.pat_agestr}}
                            </td>
                        </tr>
                        <tr>
                            <td style="float: right;">
                                签收时间：
                            </td>
                            <td>
                                {{easyData.recieve_dt}}
                            </td>
                            <td style="float: right;">
                                送检医院：
                            </td>
                            <td>
                                {{easyData.hospname}}
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
            <div v-else style="height: 100%">
                <rm-layout-right splitcolor="#F8F8FF" movingcolor="#e7e7ee" :splitwidth="5" :fixsize="450" :minfixsize="300">
                    <template v-slot:fix>
                        <rm-layout-top splitcolor="white" :splitwidth="5" :fixsize="130" :canDrag="false">
                            <template v-slot:fix>
                                <div style="height: 130px; border: 1px solid #ccc">
                                    <div style="height: 100%; text-align: center; color: red;
                                    border: 1px solid #ccc; over-flow: auto; font-size: 18px"
                                    v-html="txtbarcodeList"
                                     v-if="txtbarcodeList == ''"></div>
                                    <div  v-else  style="height: 100%; text-align: center; color: red;
                                    border: 1px solid #ccc; over-flow: auto; font-size: 18px"
                                    v-for="(item, index) in txtbarcodeList" v-html="item" :key="index" >
                                </div>
                                </div>
                            </template>
                            <div style="height: 100%; width: 100%; background-color: #ddccbb">
                                <rmLabReportReq :PatientInfo="PatientInfo" :specno="specno" :rptunitid="rptunitid" :Options="Options" requesturl="LIS/LIS2/LIS212" :payinback_flag="payinback_flag" @reqtorptitem="ReqChangeSubmit" ref="reqitemdialog"></rmLabReportReq>
                            </div>
                        </rm-layout-top>
                    </template>
                    <div v-if="isshow" ref="xTableDiv" style="height: 55%">
                        <vxe-table show-overflow ref="xTable1" height="auto" row-id="id" :select-config="{ reserve: true }" :keyboard-config="keyConfig" :keyboard-local-config="keyLocalConfig" :data.sync="MasterDataDisplay" border size="mini" show-header-overflow highlight-current-row highlight-hover-row resizable stripe @current-change="detailretrieve" :edit-config="{ showIcon: false }" :cell-custom-style="xTableDiv_cellCustomStyle" :sort-config="{ trigger: 'cell' }" :row-class-name="xTableDiv_rowClass" @cell-dblclick="xTableDiv_dbclick">
                            <vxe-table-column type="index" title="NO." width="40" header-align="center" align="center"></vxe-table-column>
                            <vxe-table-column field="req_groupna" title="分单类别" width="86" header-align="center" sortable>
                                <template v-slot="{ row }">
                                    <div
                                        v-bind:style="{
                                            background: $pub.ColorChange(row.tube_color),
                                            color: $pub.colorConvert(row.tube_color),
                                        }"
                                        style="margin: 0 -10px; text-align: center"
                                    >
                                        {{ row.req_groupna }}
                                    </div>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="specimen_name" title="标本类型 " width="64" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="req_deptname" title="申请科室" width="100" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="req_wardname" title="病人病区 " width="100" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="req_bedno" title="床号 " width="60" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="pat_name" title="姓名 " width="50" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="pat_sexname" title="性别 " width="40" header-align="center" align="center" sortable></vxe-table-column>
                            <vxe-table-column field="req_statname" title="申请状态 " width="70" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="barcode" title="条码号 " width="87" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="emer_flag" title="加急 " width="40" header-align="center" align="center" sortable>
                                <template v-slot="{ row }">
                                    <div style="color: red">{{ row.emer_flag == "0" ? "" : "急" }}</div>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="sample_items" title="项目描述 " width="143" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="perform_deptname" title="执行科室 " width="83" header-align="center"></vxe-table-column>
                            <vxe-table-column field="prereport_dt" title="预出报告时间 " width="98" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                            <vxe-table-column field="prereport_comm" title="报告领取说明 " width="98" header-align="center"></vxe-table-column>
                            <vxe-table-column field="reject_reason" title="退回原因 " width="155" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="base_amount" title="基准总金额 " width="75" header-align="center" align="right" sortable></vxe-table-column>
                            <vxe-table-column field="pat_no" title="病人号 " width="105" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="req_docname" title="申请医生 " width="70" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="pat_typename" title="病人类型 " width="70" header-align="center" align="center" sortable></vxe-table-column>
                            <vxe-table-column field="sampled_dt" title="采样时间 " width="120" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="sampled_username" title="采样用户 " width="63" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="req_dt" title="申请日期 " width="120" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="pat_agestr" title="年龄 " width="60" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="hospname" title="送检医院 " width="133" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="recieve_dt" title="签收时间 " width="120" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="rcvmsg" title="签收消息 " width="165" header-align="center"></vxe-table-column>
                            <template v-slot:fix>
                                <div style="font-size: 17px; padding-left: 3px; background-color: #fff; overflow: auto">
                                    <span v-for="(item, index) in SumInfo" :key="index"
                                        ><span
                                            style="font-weight: bold; margin-left: 3px; display: inline-block; padding: 2px 4px"
                                            :style="{
                                                background: $pub.ColorChange(item.content.tubecolor),
                                                color: $pub.colorConvert(item.content.tubecolor),
                                            }"
                                            >{{ item.content.req_groupna }}：{{ item.content.sum }}</span
                                        >
                                    </span>
                                </div>
                            </template>
                        </vxe-table>

                    </div>
                    <div v-else ref="xTableDiv" style="height: 100%">
                        <vxe-table show-overflow ref="xTable1" height="auto" row-id="id" :select-config="{ reserve: true }" :keyboard-config="keyConfig" :keyboard-local-config="keyLocalConfig" :data.sync="MasterDataDisplay" border size="mini" show-header-overflow highlight-current-row highlight-hover-row resizable stripe @current-change="detailretrieve" :edit-config="{ showIcon: false }" :cell-custom-style="xTableDiv_cellCustomStyle" :sort-config="{ trigger: 'cell' }" :row-class-name="xTableDiv_rowClass" @cell-dblclick="xTableDiv_dbclick">
                            <vxe-table-column type="index" title="NO." width="40" header-align="center" align="center"></vxe-table-column>
                            <vxe-table-column field="req_groupna" title="分单类别" width="86" header-align="center" sortable>
                                <template v-slot="{ row }">
                                    <div
                                        v-bind:style="{
                                            background: $pub.ColorChange(row.tube_color),
                                            color: $pub.colorConvert(row.tube_color),
                                        }"
                                        style="margin: 0 -10px; text-align: center"
                                    >
                                        {{ row.req_groupna }}
                                    </div>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="specimen_name" title="标本类型 " width="64" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="req_deptname" title="申请科室" width="100" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="req_wardname" title="病人病区 " width="100" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="req_bedno" title="床号 " width="60" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="pat_name" title="姓名 " width="50" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="pat_sexname" title="性别 " width="40" header-align="center" align="center" sortable></vxe-table-column>
                            <vxe-table-column field="req_statname" title="申请状态 " width="70" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="barcode" title="条码号 " width="87" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="emer_flag" title="加急 " width="40" header-align="center" align="center" sortable>
                                <template v-slot="{ row }">
                                    <div style="color: red">{{ row.emer_flag == "0" ? "" : "急" }}</div>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="sample_items" title="项目描述 " width="143" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="perform_deptname" title="执行科室 " width="83" header-align="center"></vxe-table-column>
                            <vxe-table-column field="prereport_dt" title="预出报告时间 " width="98" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                            <vxe-table-column field="prereport_comm" title="报告领取说明 " width="98" header-align="center"></vxe-table-column>
                            <vxe-table-column field="reject_reason" title="退回原因 " width="155" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="base_amount" title="基准总金额 " width="75" header-align="center" align="right" sortable></vxe-table-column>
                            <vxe-table-column field="pat_no" title="病人号 " width="105" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="req_docname" title="申请医生 " width="70" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="pat_typename" title="病人类型 " width="70" header-align="center" align="center" sortable></vxe-table-column>
                            <vxe-table-column field="sampled_dt" title="采样时间 " width="120" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="sampled_username" title="采样用户 " width="63" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="req_dt" title="申请日期 " width="120" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="pat_agestr" title="年龄 " width="60" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="hospname" title="送检医院 " width="133" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="recieve_dt" title="签收时间 " width="120" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="rcvmsg" title="签收消息 " width="165" header-align="center"></vxe-table-column>
                            <template v-slot:fix>
                                <div style="font-size: 17px; padding-left: 3px; background-color: #fff; overflow: auto">
                                    <span v-for="(item, index) in SumInfo" :key="index"
                                        ><span
                                            style="font-weight: bold; margin-left: 3px; display: inline-block; padding: 2px 4px"
                                            :style="{
                                                background: $pub.ColorChange(item.content.tubecolor),
                                                color: $pub.colorConvert(item.content.tubecolor),
                                            }"
                                            >{{ item.content.req_groupna }}：{{ item.content.sum }}</span
                                        >
                                    </span>
                                </div>
                            </template>
                        </vxe-table>
                    </div>
                    <div v-if="isshow" ref="xTableDiv1" style="height: 45%">
                        <vxe-table show-overflow ref="xTable2" height="auto" row-id="id1" :select-config="{ reserve: true }" :keyboard-config="keyConfig" :keyboard-local-config="keyLocalConfig" :data.sync="mainreqdata" border size="mini" show-header-overflow highlight-current-row highlight-hover-row resizable stripe :edit-config="{ showIcon: false }" :cell-custom-style="xTableDiv_cellCustomStyle" :sort-config="{ trigger: 'cell' }" :row-class-name="xTableDiv_rowClass">
                            <vxe-table-column type="index" title="NO." width="40" header-align="center" align="center"></vxe-table-column>
                            <vxe-table-column field="req_groupna" title="分单类别" width="86" header-align="center" sortable>
                                <template v-slot="{ row }">
                                    <div
                                        v-bind:style="{
                                            background: $pub.ColorChange(row.tube_color),
                                            color: $pub.colorConvert(row.tube_color),
                                        }"
                                        style="margin: 0 -10px; text-align: center"
                                    >
                                        {{ row.req_groupna }}
                                    </div>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="specimen_name" title="标本类型 " width="64" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="req_deptname" title="申请科室" width="100" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="req_wardname" title="病人病区 " width="100" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="sampled_dt" title="采样时间 " width="120" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="sampled_username" title="采样用户 " width="63" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="req_bedno" title="床号 " width="60" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="pat_name" title="姓名 " width="50" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="pat_sexname" title="性别 " width="40" header-align="center" align="center" sortable></vxe-table-column>
                            <vxe-table-column field="pat_agestr" title="年龄 " width="60" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="req_statname" title="申请状态 " width="70" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="barcode" title="条码号 " width="87" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="emer_flag" title="加急 " width="40" header-align="center" align="center" sortable>
                                <template v-slot="{ row }">
                                    <div style="color: red">{{ row.emer_flag == "0" ? "" : "急" }}</div>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="sample_items" title="项目描述 " width="143" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="prereport_dt" title="预出报告时间 " width="98" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                            <vxe-table-column field="perform_deptname" title="执行科室 " width="83" header-align="center"></vxe-table-column>
                            <vxe-table-column field="prereport_comm" title="报告领取说明 " width="98" header-align="center"></vxe-table-column>
                            <vxe-table-column field="reject_reason" title="退回原因 " width="155" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="base_amount" title="基准总金额 " width="75" header-align="center" align="right" sortable></vxe-table-column>
                            <vxe-table-column field="pat_no" title="病人号 " width="105" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="req_docname" title="申请医生 " width="70" header-align="center" sortable></vxe-table-column>
                            <vxe-table-column field="pat_typename" title="病人类型 " width="70" header-align="center" align="center" sortable></vxe-table-column>
                            <vxe-table-column field="req_dt" title="申请日期 " width="120" header-align="center" sortable></vxe-table-column>

                            <vxe-table-column field="hospname" title="送检医院 " width="133" header-align="center" sortable></vxe-table-column>
                            <!-- <template v-slot:fix>

                            </template> -->
                        </vxe-table>
                        <div class="fixbottom" >
                            <div style="font-size: 17px; padding-left: 3px; background-color: #fff; overflow: auto">
                                    <span><span style="font-weight: bold; margin-left: 3px;
                                    display: inline-block; padding: 2px 4px; background: black;
                                     color: white">未收:{{ maintotal }}</span>
                                    </span>
                                </div>
                        </div>
                    </div>
                </rm-layout-right>
            </div>
        </div>

        <el-dialog title="签收提示" :visible.sync="dialog_rcvpoptips" v-el-drag-dialog :close-on-click-modal="false" width="50%" :destroy-on-close="true" :show-close="false">
            <div>
                <div v-for="msg in rcv_msgList" :key="msg.title" style="over-flow: auto">
                    <h3 style="color: red">{{ msg.Item1 }}</h3>
                    <h5 v-html="msg.Item2"></h5>
                </div>
            </div>

            <div slot="footer" class="dialog-footer" v-if="rcv_flag == 0">
                <el-button icon="el-icon-circle-check" @click="dialogok()" ref="btnfocus0" @keyup.right.native="chkbtnfun($refs.btnfocus1)">是</el-button>
                <el-button icon="el-icon-circle-close" @click="dialogcancel" ref="btnfocus1" :autofocus="true" @keyup.left.native="chkbtnfun($refs.btnfocus0)">否</el-button>
            </div>

            <div slot="footer" class="dialog-footer" v-else-if="rcv_flag == -1">
                <el-button icon="el-icon-circle-check" ref="btnfocus2" @click="dialogcancel" :autofocus="true">确定</el-button>
            </div>

            <div slot="footer" class="dialog-footer" v-if="rcv_flag == 1">
                <el-button icon="el-icon-circle-check" @click="dialogok()" ref="btnfocus3" @keyup.right.native="chkbtnfun($refs.btnfocus4)">确定</el-button>
                <el-button icon="el-icon-circle-close" @click="dialogcancel" ref="btnfocus4" :autofocus="true" @keyup.left.native="chkbtnfun($refs.btnfocus3)">确定并清除</el-button>
            </div>

            <div slot="footer" class="dialog-footer" v-if="rcv_flag == 2">
                <el-button icon="el-icon-circle-check" @click="dialogok()" ref="btnfocus5" @keyup.right.native="chkbtnfun($refs.btnfocus6)">签收</el-button>
                <el-button icon="el-icon-circle-check" @click="dialogcancel(1)" ref="btnfocus6" @keyup.right.native="chkbtnfun($refs.btnfocus7)" @keyup.left.native="chkbtnfun($refs.btnfocus5)">不签收</el-button>
                <el-button icon="el-icon-circle-close" @click="dialogcancel(2)" ref="btnfocus7" :autofocus="true" @keyup.left.native="chkbtnfun($refs.btnfocus6)">不签收并从列表中剔除</el-button>
            </div>
        </el-dialog>
        <!--标签打印-->
        <el-dialog title="标签选择打印" :visible.sync="dialog_labprintdialog" v-el-drag-dialog :close-on-click-modal="false" width="90%" :destroy-on-close="true">
            <div style="width: 100%; height: 460px">
                <div style="width: 100%; height: 40px; float: left">
                    <table>
                        <tr>
                            <td>标签份数</td>
                            <td>
                                <el-select v-model="labnum">
                                    <el-option v-for="item in labnumOption" :value="item.value" :key="item.value" :label="item.label"></el-option>
                                </el-select>
                            </td>
                            <td>
                                <el-button icon="el-icon-printer" @click="PrintLab($event)">打印标签</el-button>
                            </td>
                            <td>
                                <el-button icon="el-icon-printer" @click="PrintReqList($event)">打印申请单</el-button>
                            </td>
                            <td>
                                <el-button icon="el-icon-close" @click="dialog_labprintdialog = false">取消</el-button>
                            </td>
                        </tr>
                    </table>
                </div>
                <div style="width: 100%; height: 415px; float: left">
                    <vxe-table show-overflow ref="xTablePop" height="auto" :select-config="{ reserve: true }" :keyboard-config="keyConfig" :keyboard-local-config="keyLocalConfig" :data.sync="MasterData" border size="mini" show-header-overflow highlight-current-row highlight-hover-row resizable stripe>
                        <vxe-table-column type="selection" width="50" header-align="center" align="center"></vxe-table-column>
                        <vxe-table-column field="req_groupna" title="分单类别" width="106" header-align="center"></vxe-table-column>
                        <vxe-table-column field="specimen_name" title="标本类型 " width="74" header-align="center"></vxe-table-column>
                        <vxe-table-column field="req_deptname" title="申请科室" width="104" header-align="center"></vxe-table-column>
                        <vxe-table-column field="req_wardname" title="病人病区 " width="105" header-align="center"></vxe-table-column>
                        <vxe-table-column field="req_bedno" title="床号 " width="74" header-align="center"></vxe-table-column>
                        <vxe-table-column field="pat_name" title="姓名 " width="70" header-align="center"></vxe-table-column>
                        <vxe-table-column field="pat_sexname" title="性别 " width="48" header-align="center" align="center"></vxe-table-column>
                        <vxe-table-column field="req_statname" title="申请状态 " width="88" header-align="center"></vxe-table-column>
                        <vxe-table-column field="barcode" title="条码号 " width="107" header-align="center"></vxe-table-column>
                        <vxe-table-column field="emer_flag" title="加急 " width="50" header-align="center" align="center">
                            <template v-slot="{ row }">
                                <div style="color: red">{{ row.emer_flag == "0" ? "" : "急" }}</div>
                            </template>
                        </vxe-table-column>
                        <vxe-table-column field="sample_items" title="项目描述 " width="203" header-align="center"></vxe-table-column>
                        <vxe-table-column field="prereport_dt" title="预出报告时间 " width="98" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                        <vxe-table-column field="prereport_comm" title="报告领取说明 " width="98" header-align="center"></vxe-table-column>
                        <vxe-table-column field="reject_reason" title="退回原因 " width="205" header-align="center"></vxe-table-column>
                        <vxe-table-column field="base_amount" title="基准总金额 " width="85" header-align="center" align="right"></vxe-table-column>
                        <vxe-table-column field="pat_no" title="病人号 " width="105" header-align="center"></vxe-table-column>
                        <vxe-table-column field="req_docname" title="申请医生 " width="75" header-align="center"></vxe-table-column>
                        <vxe-table-column field="pat_typename" title="病人类型 " width="77" header-align="center" align="center"></vxe-table-column>
                        <vxe-table-column field="create_dt" title="条码生成时间 " width="130" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd HH:mm:ss']"></vxe-table-column>
                        <vxe-table-column field="create_username" title="条码生成用户 " width="104" header-align="center"></vxe-table-column>
                        <vxe-table-column field="reject_username" title="退回用户 " width="90" header-align="center"></vxe-table-column>
                        <vxe-table-column field="reject_dt" title="退回时间 " width="98" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                        <vxe-table-column field="print_dt" title="打印日期 " width="126" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd HH:mm:ss']"></vxe-table-column>
                        <vxe-table-column field="print_username" title="打印用户 " width="78" header-align="center"></vxe-table-column>
                        <vxe-table-column field="print_count" title="打印次数 " width="78" header-align="center" align="center"></vxe-table-column>
                        <vxe-table-column field="sampled_dt" title="采样时间 " width="121" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd HH:mm:ss']"></vxe-table-column>
                        <vxe-table-column field="sampled_username" title="采样用户 " width="93" header-align="center"></vxe-table-column>
                        <vxe-table-column field="req_dt" title="申请日期 " width="125" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd HH:mm:ss']"></vxe-table-column>
                        <vxe-table-column field="pat_diag" title="临床诊断 " width="133" header-align="center"></vxe-table-column>
                        <vxe-table-column field="pat_agestr" title="年龄字串 " width="78" header-align="center"></vxe-table-column>
                        <vxe-table-column field="pat_id" title="病人唯一号 " width="107" header-align="center"></vxe-table-column>
                        <vxe-table-column field="inp_date" title="入院日期 " width="93" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                        <vxe-table-column field="send_dt" title="护工交接时间 " width="126" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                        <vxe-table-column field="send_username" title="送出护工 " width="93" header-align="center"></vxe-table-column>
                        <vxe-table-column field="recieve_dt" title="检验科接收时间 " width="126" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd HH:mm:ss']"></vxe-table-column>
                        <vxe-table-column field="recieve_username" title="检验科接收用户 " width="123" header-align="center"></vxe-table-column>
                        <vxe-table-column field="charge_dt" title="计价时间 " width="125" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd HH:mm:ss']"></vxe-table-column>
                        <vxe-table-column field="charge_username" title="计价人 " width="74" header-align="center"></vxe-table-column>
                        <vxe-table-column field="amount" title="实收总金额 " width="100" header-align="center" align="right"></vxe-table-column>
                        <vxe-table-column field="charge_flag" title="收费标志 " width="73" header-align="center" :edit-render="{ name: 'select', options: $opt.chargeOption }"></vxe-table-column>
                        <vxe-table-column field="pat_cardno" title="就诊卡号 " width="129" header-align="center"></vxe-table-column>
                        <vxe-table-column field="req_comm" title="医生备注 " width="197" header-align="center"></vxe-table-column>
                        <vxe-table-column field="pat_birth" title="病人生日 " width="90" header-align="center" :formatter="['toDateString', 'yyyy-MM-dd']"></vxe-table-column>
                        <vxe-table-column field="inp_id" title="住院标识 " width="76" header-align="center"></vxe-table-column>
                        <vxe-table-column field="charge_typename" title="收费类型 " width="82" header-align="center"></vxe-table-column>
                        <vxe-table-column field="perform_deptname" title="执行科室 " width="83" header-align="center"></vxe-table-column>
                        <vxe-table-column field="original_reqno" title="原始单号 " width="90" header-align="center"></vxe-table-column>
                        <vxe-table-column field="reject_count" title="退回次数 " width="70" header-align="center" align="right"></vxe-table-column>
                        <vxe-table-column field="sample_detail" title="标本备注说明 " width="101" header-align="center"></vxe-table-column>
                        <vxe-table-column field="hospname" title="送检医院 " width="133" header-align="center"></vxe-table-column>
                        <vxe-table-column field="rcvmsg" title="签收消息 " width="165" header-align="center"></vxe-table-column>
                    </vxe-table>
                </div>
            </div>
        </el-dialog>
        <!--签收打包条码-->
        <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="签收打包条码" :visible.sync="dialogPackageRcv" width="1000px" :show-close="false">
            <rm-PackageBar-Rcv @change="packageChange" @cancel="packageCancel" :tableData1="packagedata" :remindtxt="remindstr" @appendDialog="appendDialog" :userinfoval="userinfoval" :trans="trans" name="LIS212"></rm-PackageBar-Rcv>
        </el-dialog>
        <!--标本签收-->
        <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="标本签收" :visible.sync="dialogSpecimenRcv" width="1000px" :show-close="false">
            <rm-Specimen-Rcv @change="specimenChange" :tableData2="specimenData" @cancel="specimenCancel" :userinfoval="userinfoval" :packagebarcode="packagebarcode" name="LIS212" :key="specimenkey"></rm-Specimen-Rcv>
        </el-dialog>
        <!--退回原因-->
        <el-dialog v-el-drag-dialog :close-on-click-modal="false" title="提示" :visible.sync="dialogVisible" width="500px">
            <div>
                <table style="width: 100%; font-size: 12px; padding: 5" border="0">
                    <tr>
                        <td style="text-align: right">原 因：</td>
                        <td>
                            <el-select placeholder="请选择退回原因" style="width: 90%" v-model="reject_reason" @keyup.enter.native="inputautofocus('lguward')">
                                <el-option :key="index" :label="item.label" :value="item.value" v-for="(item, index) in RejectiReasonOption"></el-option>
                            </el-select>
                        </td>
                        <td>临床通知人:</td>
                        <td><rm-ddl-common datatype="userinfo" dataname="临床通知人" v-model="tellman" width="100%"></rm-ddl-common></td>
                        <!-- @change="diagUserInfoChange"  -->
                    </tr>
                    <tr>
                        <td style="text-align: right; padding-top: 3px">备 注：</td>
                        <td colspan="3"><el-input v-model="description" clearable placeholder="备注" style="width: 100%; padding-top: 3px" size="medium" type="textarea" :rows="3"></el-input></td>
                    </tr>
                    <tr v-show="islogin">
                        <td style="text-align: right; padding-top: 3px">工 号：</td>
                        <td colspan="3"><el-input v-model="loginuserno" clearable placeholder="工号" style="width: 100%; padding-top: 3px"></el-input></td>
                    </tr>
                    <tr v-show="islogin">
                        <td style="text-align: right; padding-top: 3px">密 码：</td>
                        <td colspan="3"><el-input v-model="loginpwd" type="password" clearable placeholder="密码" style="width: 100%; padding-top: 3px"></el-input></td>
                        <!-- type="password" -->
                    </tr>
                    <tr>
                        <td colspan="4" style="text-align: center">
                            <span slot="footer" class="dialog-footer">
                                <el-button @click="CommitTips()">确 定</el-button>
                                <el-button @click="CancelTips()">取 消</el-button>
                            </span>
                        </td>
                    </tr>
                </table>
            </div>
        </el-dialog>
        <!--取消签收原因-->
        <el-dialog v-el-drag-dialog :close-on-click-modal="false" title="提示" :visible.sync="dialogCancelVisible" width="500px">
            <div>
                <table style="width: 100%; font-size: 12px; padding: 5" border="0">
                    <tr>
                        <td style="text-align: right">取消原因：</td>
                        <td colspan="3"><el-input v-model="cancel_reason" clearable   style="width: 100%; padding-top: 3px" size="medium" type="textarea" :rows="3"></el-input></td>
                    </tr>
                    <tr>
                        <td colspan="4" style="text-align: center">
                            <span slot="footer" class="dialog-footer">
                                <el-button @click="cancelCommitTips()">确 定</el-button>
                                <el-button @click="cancelCancelTips()">取 消</el-button>
                            </span>
                        </td>
                    </tr>
                </table>
            </div>
        </el-dialog>
        <rm-floatwindow v-rm-drag-window :visible="dialogfloatwindowVisible" :winStyle="floatwindowstyle2" title="分类放置提示" @close="FloatClose($event)">
            <div style="font-size: 16px; color: red">采样时间: {{ this.SampledDate }}</div>
            <div :style="floatwindowcolor">
                <div v-if="this.emerflag == '(急)'" style="font-size: 80px; text-align: center;background-color: red;color:white;">{{ this.emerflag }}</div>
                <div style="font-size: 80px; text-align: center">{{ this.sorting_tips }}</div>
                <div style="font-size: 80px; text-align: center">{{ this.description }}</div>
            </div>
        </rm-floatwindow>
    </div>
</template>

<script type="text/javascript">
import input from "../../../../element-ui/packages/input/src/input.vue";
import rmLabReportReq from "../../../rmcompents/rm_Lab_Report_Sub/REQ";
import md5 from "js-md5";
import XE from "xe-utils";
export default {
    components: { input },
    name: "LIS212",
    data() {
        return {
            //运送人
            userinfoval: "",
            // 打印选项
            radioPrintWays: "1",
            // 打印选项
            radioPrintWaysOption: [
                { label: "不打印", value: "1" },
                { label: "总是打印", value: "2" },
                { label: "正常打印", value: "3" },
            ],
            //打印选项
            chkprint: "1",
            //打印选项
            chkprintOption: [
                { label: "打印标签", value: "1" },
                { label: "打印申请单", value: "2" },
                { label: "都打印", value: "3" },
            ],
            //标签份数
            labnum: "1",
            //标签份数
            labnumOption: [
                { label: "1", value: "1" },
                { label: "2", value: "2" },
                { label: "3", value: "3" },
                { label: "4", value: "4" },
                { label: "5", value: "5" },
                { label: "6", value: "6" },
                { label: "7", value: "7" },
            ],
            //条码号
            txtbarcode: "",
            //上次条码号，用来避免连续重复输入的问题
            lasttxtbarcode: "",
            //条码框placeholder内容
            barcodeholder: "请扫描条码号",
            //签收人
            recieveuser: "",
            //执行科室
            performdept: "",
            //可签收标本类型
            allowrecievetype: "",
            //如果是1 ，则表示签收异常弹出对话框
            rcv_invalidmsgbox: "",
            // 似乎如果是1， 则 判断是否是重复签收的
            rcv_dupnomsgbox: "",
            //如果是1， 则列表中显示无效签收的数据
            rcv_showinvalid: "",
            //右边消息栏消息
            txtbarcodeList: "",
            //似乎和上面的作用相同，但是是临时存放的
            txtbarcodeListcopy: "",
            //主表格数据
            MasterData: [],
            //主表格数据真正用来显示的，为提高性能进行了分离
            MasterDataDisplay: [],
            //主数据异步同步标志
            MasterDataSyncFlag: false,
            //最后更新的时间戳
            lastMasterChangeFlag: "",
            //明细表数据
            detail: [],
            //首次加载的开关，保证只调用一次
            okFirstLoading: true,
            //签收包条码对话框
            dialogPackageRcv: false,
            //标本签收对话框
            dialogSpecimenRcv: false,
            //签收提示对话框
            dialog_rcvpoptips: false,
            //签收提示使用的是否异步标志记录
            rcv_async: false,
            //签收提示使用的条码记录
            rcv_barcode: "",
            //签收消息，应该也是用在对话框传递上
            rcv_msg: "",
            //签收提示 界面， 根据标志显示不同的内容，0显示两个按钮，-1显示一个确定按钮, 1-异步处理时显示两个按钮的情况，2-异步处理的时候三个按钮的情况
            rcv_flag: "",
            //标签选择打印对话框
            dialog_labprintdialog: false,
            //表格键盘配置
            keyConfig: {
                isDel: true,
                isTab: true,
                isEdit: true,
            },
            //表格键盘配置
            keyLocalConfig: {
                isArrow: true,
            },
            //签收提示对话框上的  消息列表
            rcv_msgList: [],
            //同步的时候用来记录正在处理的主表记录
            lastmaster: [],
            //同步的时候用来记录正在处理的从表记录
            lastdetail: [],
            //当前用户
            userno: this.$tool.getSession(this.$tool.loginuserno),
            //Y正常签收，N非正常签收，只有normalRcvFlag="Y"的打印
            normalRcvFlag: "Y",
            //主表下面的大方块汇总统计
            SumInfo: [],
            MainSumInfo: [],
            //包条码数据
            packagedata: [],
            //包条码对话框信息提示
            remindstr: "",
            //标本签收数据
            specimenData: [],
            //检验申请单样式
            ReqRptstyle: "",
            //送达清单样式
            ReqRcvstyle: "",
            //记录已经写到主表中的条码，用来判断是否有重复条码，不在主表中直接查找，这样可以提高速度
            barcoderec: [],
            //同步时延迟显示用，通过记录最后一个barcode来取消已经被覆盖的显示请求
            runningbarcode: "",
            dialogVisible: false,
            //退回条码
            RejetTempRow: {},
            //取消签收条码
            CancelRecieveRow: {},
            //退回原因选项
            RejectiReasonOption: [],
            //退回原因
            reject_reason: "",
            //退回备注
            description: "",
            //是否异步处理方式
            isasync: false,
            //异步时正在处理的列表
            asyncrunningbarcode: "",
            //扫码后台进程运行标志
            timeoutrunning: false,
            //记录包条码信息
            trans: "",
            //包条码号
            packagebarcode: "",
            //申请项目组件
            PatientInfo: {
                barcode: this.txtbarcode,
                reportid: null,
                rechkflag: "0",
                report_user: this.$tool.getSession(this.$tool.loginuserno),
            },
            specno: "",
            rptunitid: 0,
            //护工登陆校验
            sendusercheckout: "",
            Options: {},
            islogin: false,
            loginuserno: "",
            loginpwd: null,
            mainreqdata: [],
            maintotal: 0,
            isshow: false, // 是否显示待签收列表
            isquerymode: "", // 查询模式
            tellman: "", // 临床通知人
            showreqgroupdetailcnt: "0",
            specimenkey: 0,
            payinback_flag: "0",
            dialogfloatwindowVisible: false, // 提示浮动窗口显示标志
            floatwindowstyle2: "top:100px;left:calc(50% + 20px );width:750px;height:300px", // 浮动窗口回传样式
            sorting_tips: "", // 分拣提示
            description: "", // 备注
            SampledDate: "",
            floatwindowcolor: "",
            isshowsignfloatwindow: "",
            cancel_reason:"", // 取消原因
            dialogCancelVisible: false, // 取消签收原因弹窗
            rcvusetts :"",
            rcvtts_normal :"",
            rcvtts_emer :"",
            rcvshowsumdetails :"",
            emerflag: "",
            isEasyMode: "0",
            easyData: [],
        };
    },
    components: { rmLabReportReq },
    watch: {
        isasync(val) {
            this.$tool.setLocalConfig("lis212_async", val ? "Y" : "N");
        },
        MasterData(val) {
            //异步时，一旦主数据变化，启动可延迟处理
            var that = this;
            if (!this.timeoutrunning) {
                this.timeoutrunning = true;
                setTimeout(() => {
                    that.DealBarCode(that);
                }, 100);
            }
            if (!that.MasterDataSyncFlag) {
                that.MasterDataSyncFlag = true;
                setTimeout(() => {
                    that.MasterDataDisplay = that.MasterData.slice(0, 30);
                    that.MasterDataSyncFlag = false;
                }, 500);
            }

            let cticks = new Date().getTime();
            that.lastMasterChangeFlag = cticks;
            setTimeout(() => {
                if (that.lastMasterChangeFlag == cticks) {
                    that.MasterDataDisplay = that.MasterData.slice(0);
                } else {
                    // console.log("pass...", cticks, that.lastMasterChangeFlag);
                }
                that.MasterDataSyncFlag = false;
            }, 2000);
        },
        dialog_rcvpoptips(newval) {
            //签收提示对话框状态变化
            if (!newval) {
                //处理扫描条码时打印
                this.IsSelectPrint("");
            }
        },
    },
    computed: {},
    created() {
        this.getoption();
        let syncstr = this.$tool.getLocalConfig("lis212_async");
        if (syncstr) {
            this.isasync = syncstr == "Y";
        }
        let printways = localStorage.getItem("LIS212_PRINT_WAYS");
        this.radioPrintWays = printways ? printways : "1";
        let chkprint = localStorage.getItem("LIS212_CHECK_PRINT");
        this.chkprint = chkprint ? chkprint : "1";
        let EasyModeCookie = localStorage.getItem("rm_LIS212_isEasyMode");
        this.isEasyMode = EasyModeCookie ? EasyModeCookie : "0";
    },
    mounted() {
        this.$refs.barcode.focus();
        // this.testasync();
    },
    activated() {
        this.$refs.barcode.focus();
    },
    updated() {
        let that = this;
        that.$nextTick(() => {
            if (!this.dialogVisible && this.sendusercheckout != "2") that.$refs.barcode.focus();
        });
        if (that.okFirstLoading && this.isEasyMode != '1') {
            that.$nextTick(() => {
                let currentrow = that.$refs.xTable1.getData(0);
                if (currentrow) {
                    that.okFirstLoading = false;
                    that.$refs.xTable1.setCurrentRow(currentrow);
                    that.Exedetailretrieve(that, currentrow);
                } else {
                    that.$refs.xTable1.setCurrentRow(null);
                }
            });
        }
    },
    methods: {
        PrintWaysChange() {
            localStorage.setItem("LIS212_PRINT_WAYS", this.radioPrintWays);
        },
        ChkPrintChange() {
            localStorage.setItem("LIS212_CHECK_PRINT", this.chkprint);
        },
        EasyModeChange() {
            localStorage.setItem("rm_LIS212_isEasyMode", this.isEasyMode);
        },
        //标本退回
        Rejet() {
            if(this.isEasyMode == '1'){
                this.RejetTempRow = this.MasterDataDisplay[0];
            }
            else {
                this.RejetTempRow = this.$refs.xTable1.getCurrentRow();
            }
            if (this.RejetTempRow == null) {
                this.$message.warning("请选择标本！");
                return;
            }
            if (this.RejetTempRow.req_stat == "8") {
                this.$message.warning("该标本已退回！");
                return;
            }

            this.dialogVisible = true;
            this.loginuserno = "";
            this.loginpwd = null;
        },
        //取消签收
        cancelbarcode() {
            if(this.isEasyMode == '1'){
                this.CancelRecieveRow = this.MasterDataDisplay[0];
            }
            else {
                this.CancelRecieveRow = this.$refs.xTable1.getCurrentRow();
            }
            if (this.CancelRecieveRow == null) {
                this.$message.warning("请选择标本！");
                return;
            }
            if (this.CancelRecieveRow.req_stat == "8") {
                this.$message.warning("该标本已退回！");
                return;
            }
            this.dialogCancelVisible = true;
            this.cancel_reason = null;
        },

        cancelCancelTips() {
            this.dialogCancelVisible = false;
            this.cancel_reason = null;
        },

        // 标本退回 弹窗确定按钮
        cancelCommitTips() {
            let barcode = this.CancelRecieveRow.barcode;
            this.$tool
                .request({
                    url: "LIS/LIS2/LIS212",
                    method: "post",
                    data: {
                        action: "cancelbarcode",
                        barcode: barcode,
                        cancelreason:this.cancel_reason,
                        iscencel: "0",
                    },
                })
                .then((res) => {
                    this.dialogCancelVisible = false;
                    if (res.flag == 1) {
                        // this.$refs.xTable1.remove(this.CancelRecieveRow);
                        let processeditem = this.MasterData.findIndex((e) => e.barcode == barcode);
                        let master = this.MasterData.find((e) => e.barcode == barcode);
                        this.MasterData.splice(processeditem, 1);
                        this.$message.success("取消签收成功！");
                        if(this.isEasyMode == '1'){
                            this.easyData = [];
                        }
                        this.ClearFloatWindows();//清空分拣提示
                        this.barcodeholder = barcode + "  取消签收成功！";
                        let temp = [];
                        temp.push(barcode + "  取消签收成功！");
                        let that = this;
                        that.removerromdetailcnt(master, that);
                        if (this.isshow) {
                            let querymode = this.isquerymode; //1 病区模式|2 科室模式|3 医院模式
                            let querystr = "";
                            if (querymode == 1) {
                                querystr = this.CancelRecieveRow.req_wardno;
                            } else if (querymode == 2) {
                                querystr = this.CancelRecieveRow.req_deptno;
                            } else {
                                querystr = this.CancelRecieveRow.hospcode;
                            }
                            if (querystr != "") {
                                this.Gettodayreqdata(querymode, querystr);
                            }
                        }

                        this.txtbarcodeList = this.returnmsg(temp, 1);
                        // 左下统计变化
                    } else if (res.flag == -2 || res.flag == -3) {
                        this.$confirm(res.msg + "，您确定要继续取消签收吗？", {
                            confirmButtonText: "确定",
                            cancelButtonText: "取消",
                            type: "warning",
                        })
                            .then(() => {
                                this.$tool
                                    .request({
                                        url: "LIS/LIS2/LIS212",
                                        method: "post",
                                        data: {
                                            action: "cancelbarcode",
                                            barcode: barcode,
                                            cancelreason:this.cancel_reason,
                                            iscencel: "1",
                                        },
                                    })
                                    .then((res) => {
                                        if (res.flag == 1) {
                                            // this.$refs.xTable1.remove(this.CancelRecieveRow);
                                            let processeditem = this.MasterData.findIndex((e) => e.barcode == barcode);
                                            this.MasterData.splice(processeditem, 1);
                                            this.$message.success("取消签收成功！");
                                            if(this.isEasyMode == '1'){
                                                this.easyData = [];
                                            }
                                            this.ClearFloatWindows();//清空分拣提示
                                            this.barcodeholder = barcode + "  取消签收成功！";
                                            let temp = [];
                                            temp.push(barcode + "  取消签收成功！");
                                            this.Gettodayreqdata();
                                            this.txtbarcodeList = this.returnmsg(temp, 1);
                                        } else {
                                            this.$message.error("标本不可取消签收！" + res.msg);
                                            return;
                                        }
                                    })
                                    .catch((e) => {
                                        console.log("error", e);
                                    });
                            })
                            .catch((e) => {});
                    } else {
                        this.$message.error("标本不可取消签收！" + res.msg);
                        return;
                    }
                })
                .catch((e) => {
                    console.log("error", e);
                });

        },

        //扫描条码
        scanBarcode(isPackRcv, e) {
            let that = this;
            var barcodestr = e.target.value;
            that.txtbarcode = barcodestr;
            e.target.value = "";
            if (this.isshow) {
                this.isasync = false;
            }

            that.barcodeholder = "请输入条码";

            if (barcodestr.length == 0 || barcodestr == that.lasttxtbarcode) {
                return false;
            }
            that.lasttxtbarcode = barcodestr;
            setTimeout(() => {
                // 1秒以后再扫就要做出反应了
                that.lasttxtbarcode = "";
            }, 1000);

            if (barcodestr.length < 8) {
                that.barcodeholder = barcodestr + "，条码太短，请核对";
                if(this.rcvusetts == '1') {
                    this.speakMessage("条码太短，请核对");
                }
                return false;
            }

            if (isPackRcv == "1") {
                //每次扫描包条码时重置packagedata
                that.packagedata = [];
            }

            // if (this.isshow && this.mainreqdata.length > 0) {
            //     let item = this.mainreqdata.findIndex((e) => e.barcode == barcodestr);
            //     if (item < 0) {
            //         this.$message.info("【" + barcodestr + "】非本院今日采集标本");
            //     }
            // }
            // if (!this.userinfoval) {
            //     this.$alert("请先选择运送人！", "提示", {
            //         confirmButtonText: "确定"
            //     });
            //     return false;
            // }
            var reg = new RegExp("[\\u4E00-\\u9FFF]+", "g");
            if (reg.test(barcodestr)) {
                //避免弹窗后按钮回车再次走入这个事件
                return false;
            }
            //Todo   判断条码长度
            setTimeout(() => {
                //使用settimeout，因为回车键会穿透到对话框，导致对话框一闪而过
                // if (that.MasterData.findIndex((e) => e.barcode == barcodestr && e.sflag == -1) >= 0) {       //暂时不用
                //     //如果再扫一次已经提示错误的条码，则表示直接定位过去
                //     let row = that.MasterData.find((e) => e.barcode == barcodestr && e.sflag == -1);
                //     that.DealEvent(that, row.barcode, row, row.res, row.isPackRcv, true);
                // } else
                if (that.MasterData.findIndex((e) => e.scanbarcode == barcodestr ) >= 0) {
                    //即便条码重复，也需要更新分类放置提示
                    if (this.isshowsignfloatwindow == "1") {
                        //先清空弹窗内容
                        this.ClearFloatWindows();
                        if (!this.dialogfloatwindowVisible) {
                            this.dialogfloatwindowVisible = true;
                        }
                        this.GetBarcodeGroupTips(barcodestr)
                            .then((res) => {
                                //后台传出的barcode与当前扫描的barcode一致，才进行操作，避免扫描条码速度过快，返回结果不一致
                                if(res.barcode == this.txtbarcode){
                                    if(res.flag =='1'){
                                        this.SampledDate = res.master.sampled_dt;
                                        if (res.reqgroup != null) {
                                            this.sorting_tips = res.reqgroup.sorting_tips;
                                            this.description = res.reqgroup.description;
                                            this.emerflag = res.master.emer_flag == "1" ? '(急)' : '';
                                            this.floatwindowcolor = this.changecolor(res.reqgroup.tuberack_color);
                                        }
                                    }
                                    else if(res.flag == '-1'){
                                        this.ClearFloatWindows();
                                        this.$message.error("没有获取到申请信息");
                                    }
                                }
                            })
                            .catch((error) => {
                                this.ClearFloatWindows();
                                this.$message.error("获取分类提示出错：" + error);
                            });
                    }
                    if (that.rcv_dupnomsgbox == "1") {
                        that.IsSelectPrint(barcodestr);
                        if(this.isEasyMode != '1'){
                            let row = that.MasterDataDisplay.find((e) => e.scanbarcode == barcodestr  );
                            that.$refs.xTable1.setCurrentRow(row);
                            that.Exedetailretrieve(that, row);
                        }
                        let temp = [];
                        temp.push("重复签收的条码");
                        that.txtbarcodeList = that.returnmsg(temp, 1);
                        that.barcodeholder = barcodestr + "，条码重复";
                    }
                    //新增选项：浮出消息提示（不影响操作） 
                    else if (that.rcv_dupnomsgbox == "2") {
                        that.$message.error("条码重复!");
                        that.IsSelectPrint(barcodestr);
                    } else {
                        that.$alert("条码重复", "错误", {
                            confirmButtonText: "确定",
                        }).then((eitem) => {
                            that.focusBarcode();
                            that.IsSelectPrint(barcodestr);
                        });
                    }
                    if(this.rcvusetts == '1') {
                        this.speakMessage("条码重复");
                    }
                } else {
                    //客户端直接判断的放在这个前面
                    if (that.isasync) {
                        // sflag状态说明： 0-表示状态完成，这样同步的也直接兼容了， 1-表示刚刚加入，等待处理中，-1-表示错误 ，2-表示错误已读，   其他状态待扩充
                        that.MasterData.splice(0, 0, {
                            barcode: barcodestr,
                            scanbarcode: barcodestr,
                            emer_flag: 0,
                            isPackRcv: isPackRcv,
                            sflag: 1,
                        });
                    } else {
                        that.barcodeholder = barcodestr + "  正在处理......";
                        if(this.isEasyMode == '1'){
                            //进入后台前先清空
                            this.easyData = [];
                        }
                        that.BarCodeToServer(that, barcodestr, isPackRcv)
                            .then((res) => {
                                that.BarCodeServerBack(that, barcodestr, res, isPackRcv, false);
                            })
                            .catch((error) => {});
                    }
                }
            }, 1);
        },
        //清空分类放置提示浮窗信息
        ClearFloatWindows(){
            this.SampledDate = '';
            this.sorting_tips = '';
            this.description = '';
            this.emerflag = '';
            this.floatwindowcolor = '';
        },
        FloatClose(style) {
            this.dialogfloatwindowVisible = false;
        },
        changecolor(colorstr) {
            var stylestr = "height: 100%; overflow: auto; background-color:";
            stylestr += this.$pub.ColorChange(colorstr);
            stylestr += ";color:" + this.$pub.colorConvert(colorstr);
            return stylestr;
        },

        //异步循环处理已经扫进来的条码
        DealBarCode(that) {
            let dealitem = that.MasterData.find((e) => e.sflag == 1);
            if (!dealitem) {
                that.timeoutrunning = false;
                return;
            }

            that.BarCodeToServer(that, dealitem.barcode, dealitem.isPackRcv)
                .then((response) => {
                    that.BarCodeServerBack(that, dealitem.barcode, response, dealitem.isPackRcv, true);
                })
                .catch((error) => {
                    console.log("error:", error);
                    that.$confirm("出现错误：" + JSON.stringify(error), {
                        confirmButtonText: "确定",
                        cancelButtonText: "取消",
                        type: "warning",
                    })
                        .then(() => {})
                        .catch(() => {});
                })
                .finally(() => {
                    //检查是否还有未处理的
                    let nodealindex = that.MasterData.findIndex((e) => e.sflag == 1);
                    if (nodealindex >= 0) {
                        //console.log("continuing...", nodealindex);
                        setTimeout(() => {
                            that.DealBarCode(that);
                        }, 100);
                    } else {
                        // console.log("exittimeout");
                        that.timeoutrunning = false;
                    }
                });
        },
        //发送条码请求到服务器
        BarCodeToServer(that, barcodestr, isPackRcv) {
            return that.$tool.request({
                url: "LIS/LIS2/LIS212",
                method: "post",
                data: {
                    action: "scanbarcode",
                    barcode: barcodestr,
                    senduser: that.userinfoval,
                    isPackRcv: isPackRcv,
                    isEasyMode: this.isEasyMode,
                },
            });
        },
        //获取条码的分类放置提示
        GetBarcodeGroupTips(barcodestr) {
            return this.$tool.request({
                url: "LIS/LIS2/LIS212",
                method: "post",
                data: {
                    action: "getbarcodegrouptips",
                    barcode: barcodestr,
                },
            });
        },
        BarCodeServerBack(that, barcodestr, res, isPackRcv, t_issync) {
            let processeditem = -1;
            if (t_issync) {
                this.dialogfloatwindowVisible = false;
                let t_barcode = barcodestr;
                // if (res.master && res.master.barcode) {
                //     t_barcode = res.master.barcode;
                // }
                processeditem = that.MasterData.findIndex((e) => e.scanbarcode == t_barcode);
                if (res.master && isPackRcv == "1" && res.flag != 99) {
                    that.reqgroupnaInfo(res.master, that);
                }
            }
            if (res.flag == 1 || res.flag == 3) {
                if(this.isEasyMode == '1'){
                    this.easyData = res.master;
                }
                if (t_issync) {
                    if (processeditem >= 0) {
                        that.MasterData[processeditem] = res.master;
                        that.MasterData[processeditem].sflag = 0;
                        let temp = [];
                        temp.push(that.MasterData[processeditem].scanbarcode + "签收成功");
                        that.txtbarcodeList = that.returnmsg(temp, 1);
                        that.normalRcvFlag = "Y"; //正常签收，N非正常签收
                        that.IsSelectPrint(barcodestr);
                        if(this.rcvusetts == '1') {
                            this.speakMessage(this.rcvtts_normal);
                        }
                        if (res.flag == 3) {
                            that.$alert("条码号:" + res.master.scanbarcode + "为急诊标本!", "提示");
                            if(this.rcvusetts == '1') {
                                this.speakMessage(this.rcvtts_emer);
                            }
                        }
                        that.MasterData = that.MasterData.slice(0);
                        that.asyncrunningbarcode = that.MasterData[processeditem].scanbarcode;

                        this.RemoveFromMainreqdata(res.master.barcode);
                        setTimeout(() => {
                            if (that.MasterData[processeditem].scanbarcode == that.asyncrunningbarcode && this.isEasyMode != '1') {
                                that.Exedetailretrieve(that, that.MasterData[processeditem], res.details);
                            } else {
                                // console.log("pass...", that.MasterData[processeditem].barcode, that.asyncrunningbarcode);
                            }
                        }, 2000);
                    }
                } else {
                    res.master.rcvmsg = res.rcvmsg; //扫描框显示签收消息
                    //单个条码
                    //成功->直接显示信息
                    that.barcodeholder = res.rcvmsg; //列表显示签收消息
                    if (this.isshowsignfloatwindow == "1") {
                        if (!this.dialogfloatwindowVisible) {
                            this.dialogfloatwindowVisible = true;
                        }
                        this.SampledDate = res.master.sampled_dt;
                        if (res.reqgroup != null) {
                            this.sorting_tips = res.reqgroup.sorting_tips;
                            this.description = res.reqgroup.description;
                            this.emerflag = res.master.emer_flag == "1" ? '(急)' : '';
                            this.floatwindowcolor = this.changecolor(res.reqgroup.tuberack_color);
                            if(this.description == "不可签收") {
                                this.$alert("当前标本不可签收，请注意！");
                            }
                        }
                    }
                    setTimeout(() => {
                        setTimeout(() => {
                            if (res.master && isPackRcv == "1") {
                                //res.master.tube_color = await res.tube_color;
                                that.reqgroupnaInfo(res.master, that);
                            }
                        }, 100);
                        that.MasterData.splice(0, 0, res.master);
                        that.runningbarcode = res.master.scanbarcode;
                        if(this.isEasyMode != "1") {
                            that.updatedetail(res, that);
                        }
                    }, 100);
                    let temp = [];
                    temp.push(that.barcodeholder);
                    that.txtbarcodeList = that.returnmsg(temp, 1);
                    that.normalRcvFlag = "Y"; //正常签收，N非正常签收
                    that.IsSelectPrint(barcodestr);

                    if(this.rcvusetts == '1') {
                        this.speakMessage(this.rcvtts_normal);
                    }
                    if (res.flag == 3) {
                        that.$alert("当前标本为急诊标本!", "提示");
                        if(this.rcvusetts == '1') {
                            this.speakMessage(this.rcvtts_emer);
                        }
                    }
                    // 查询模式开启
                    if (this.isshow) {
                        let querymode = this.isquerymode; //1 病区模式|2 科室模式|3 医院模式
                        let querystr = "";
                        if (this.isquerymode == 1) {
                            querystr = res.master.req_wardno;
                        } else if (this.isquerymode == 2) {
                            querystr = res.master.req_deptno;
                        } else {
                            querystr = res.master.hospcode;
                        }
                        if (this.mainreqdata.length == 0) {
                            if (querystr == "" || querystr == "All") {
                                this.mainreqdata = [];
                            } else {
                                this.Gettodayreqdata(querymode, querystr);
                            }
                        } else {
                            let row = this.mainreqdata[0];
                            if (querystr == "" || querystr == "All") {
                                this.mainreqdata = [];
                            } else if ((querymode == 1 && row.req_wardno != querystr) || (querymode == 2 && row.req_deptno != querystr) || (querymode == 3 && row.hospcode != querystr)) {
                                this.Gettodayreqdata(querymode, querystr);
                            } else {
                                this.RemoveFromMainreqdata(res.master.barcode);
                            }
                        }
                    }
                }
            } else if (res.flag == 99) {
                if (t_issync) {
                    that.RemoveFromMasterData(that, barcodestr);
                }
                that.$refs.barcode.focus();
                let data = res.pkgdetail;
                let alen = res.pkgdetail.length;
                // console.log("data", res.pkgdetail);
                that.packagedata = [];
                that.dialogPackageRcv = true;
                if (data && data.length > 0) {
                    //如果存在值为req_stat=null的数据，则循环传入barcode
                    let barnum = 0;
                    for (const item of data) {
                        if (item.req_stat == null) {
                            that.getbarcodeinfo(item.barcode, that);
                        } else {
                            that.packagedata.push(item);
                        }
                        barnum++;
                        that.remindstr = "正在获取第" + barnum + "个条码信息，条码号" + item.barcode + " (" + barnum + "/" + alen + ")";
                    }
                    //console.log(res.trans);
                    that.trans = res.trans.packagebarcode + "|" + res.trans.transtype; //res.trans;
                    that.remindstr = "所有条码信息获取完成" + " (" + alen + "/" + alen + ")";
                    if(this.rcvusetts == '1') {
                        this.speakMessage(this.rcvtts_normal);
                    }
                } else {
                    that.packagedata = [];
                    that.remindstr = "没有获取到条码信息" + " ( 0 / 0)";
                    if(this.rcvusetts == '1') {
                        this.speakMessage("没有获取到条码信息");
                    }
                }
            } else {
                if (t_issync) {
                    if (processeditem >= 0) {
                        while (processeditem >= 0) {
                            if (res.master) that.MasterData[processeditem] = res.master;
                            that.MasterData[processeditem].sflag = -1; // 此处可以更精细化
                            that.MasterData[processeditem].res = {
                                msgList: res.msgList,
                                rcvmsg: res.rcvmsg,
                                details: res.details,
                                flag: res.flag,
                                errmsg: res.errmsg,
                                list: res.list,
                                pkgdetail: res.pkgdetail,
                            };
                            that.MasterData[processeditem].flag = res.flag;
                            that.MasterData[processeditem].isPackRcv = isPackRcv;
                            if(this.isEasyMode != '1'){
                                that.Exedetailretrieve(that, that.MasterData[processeditem], res.details);
                            }
                            processeditem = that.MasterData.findIndex((e) => e.scanbarcode == res.scanbarcode && e.sflag == 1);
                        }
                        that.MasterData = that.MasterData.slice(0);
                        that.countError(that);
                    }
                } else {
                    //主列表底部显示分单类别，颜色，数量
                    if (res.master && isPackRcv == "1" && res.flag != 99) {
                        //rmaster.tube_color = await res.tube_color;
                        if (this.rcv_showinvalid == "1") {
                            //列表中显示无效签收的数据,1：左下角分单信息统计加入统计，0：不加入统计
                            that.reqgroupnaInfo(res.master, that);
                        }
                    }
                    //处理错误信息
                    that.DealEvent(that, barcodestr, res.master, res, isPackRcv, false);
                    //先临时恢复一下，解决重复签收的条码点击右下角计费/退费按钮 和 修改申请项目无效的问题
                    if (res && res.master && res.master.barcode) {
                        that.PatientInfo.barcode = res.master.barcode;
                    }
                    if (this.isshowsignfloatwindow == "1" && res.flag != -1) {
                        if (!this.dialogfloatwindowVisible) {
                            this.dialogfloatwindowVisible = true;
                        }
                        this.SampledDate = res.master.sampled_dt;
                        if (res.reqgroup != null) {
                            this.sorting_tips = res.reqgroup.sorting_tips;
                            this.description = res.reqgroup.description;
                            this.emerflag = res.master.emer_flag == "1" ? '(急)' : '';
                            this.floatwindowcolor = this.changecolor(res.reqgroup.tuberack_color);
                            if(this.description == "不可签收") {
                                this.$alert("当前标本不可签收，请注意！");
                            }
                        }
                    }
                }
            }
            //that.PatientInfo.barcode = res.master.barcode;
        },
        //主表双击事件
        xTableDiv_dbclick(param, event) {
            let { row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, cell } = param;
            // console.log("event", param, event, rowIndex);
            let that = this;
            if (row.sflag && row.sflag == -1) {
                that.DealEvent(that, row.barcode, row, row.res, row.isPackRcv, true);
            } else {
                that.countError(that);
            }
        },
        DisplayMsg(that, barcodestr, rmaster, res) {
            let cmsg = "";
            if (!res) {
                if (rmaster.req_stat == "8") cmsg = rmaster.barcode + "退回成功";
                else cmsg = rmaster.barcode + "签收成功";
            } else {
                switch (res.flag) {
                    case 1:
                        cmsg = rmaster.barcode + "签收成功";
                        break;
                    case -1:
                        if (rmaster) {
                            cmsg = rmaster.barcode + " 失败!" + that.returnmsg(res.msgList).join(",");
                        } else {
                            cmsg = barcodestr + " 失败!" + that.returnmsg(res.msgList).join(",");
                        }
                        break;
                    case 0:
                        cmsg = rmaster.barcode + " 提示" + that.returnmsg(res.msgList, 2).join(",");
                        break;
                    case -99:
                        cmsg = barcodestr + " 出错!" + res.errmsg;
                        break;
                    case 98: //98/99标识包条码返回
                        cmsg = barcodestr + " 出错!" + res.list[0];
                        break;
                }
            }
            that.txtbarcodeList = [cmsg];
        },
        //从服务器返回的结果处理
        DealEvent(that, barcodestr, rmaster, res, isPackRcv, t_issync) {
            if (rmaster) rmaster.res = { flag: res.flag, msgList: res.msgList };
            let cmsg = "";
            switch (res.flag) {
                case -1:
                    if (rmaster) {
                        cmsg = rmaster.barcode + " 失败!" + that.returnmsg(res.msgList).join(",");
                    } else {
                        cmsg = barcodestr + " 失败!" + that.returnmsg(res.msgList).join(",");
                    }
                    if(that.rcvusetts == '1') {
                        that.speakMessage(that.returnmsg(res.msgList).join(","));
                    }
                    if (t_issync) {
                        that.txtbarcodeList = [cmsg];
                        that.rcv_flag = 1;
                        // console.log("res", res);
                        that.rcv_msgList = res.msgList;
                        that.dialogshow(rmaster.barcode, true);
                    } else {
                        //失败(有弹窗)->点确定->关闭dialog
                        that.barcodeholder = cmsg;
                        that.lastmaster = rmaster;
                        if (res.details) {
                            that.lastdetail = res.details.filter((item) => item.parent_itemcode == "" || item.parent_itemcode == item.req_itemcode);
                        }
                        that.rcv_msgList = res.msgList;
                        that.rcv_msg = res.rcvmsg;
                        that.rcv_flag = -1;
                        let flag = true; //判断是不是重复签收的条码
                        if (that.rcv_dupnomsgbox == "1") {
                            //不提示
                            //判断是否是重复签收的
                            if (that.returnmsg(res.msgList).indexOf("重复签收的条码") > -1) {
                                flag = false;
                                that.IsSelectPrint("");
                            }
                        }
                        //新增选项：浮出消息提示（不影响操作）
                        else if (that.rcv_dupnomsgbox == "2") {
                            //浮出消息提示
                            //判断是否是重复签收的
                            if (that.returnmsg(res.msgList).indexOf("重复签收的条码") > -1) {
                                that.$message.error("重复签收的条码!");
                                flag = false;
                                that.IsSelectPrint("");
                            }
                        }

                        if(res.errorResult == "only_repeat"){
                            //只有重复
                            if(flag){
                                //为ture，且只有重复，说明上面未处理过重复问题，提示重复
                                that.rcv_msgList = [{Item1 : "重复签收的条码",Item2:""}];
                                that.dialogshow(that.barcodeholder, false);
                            }
                        }
                        else if(res.errorResult == "only_wrong"){
                            //只有其他错误，判断是否需要弹窗提示
                            if (that.rcv_invalidmsgbox == "1") {
                                that.dialogshow(that.barcodeholder, false);
                            }
                        }
                        else if(res.errorResult == "orepeat_and_wrong"){
                            //混合重复和其他错误
                            if(flag){
                                //为ture，且有重复，说明上面未处理过重复问题，需要提示重复，同时判断是否需要提示其他错误信息
                                if (that.rcv_invalidmsgbox == "1") {
                                    that.dialogshow(that.barcodeholder, false);
                                }
                                else {
                                    //只需要提示重复即可
                                    that.rcv_msgList = [{Item1 : "重复签收的条码",Item2:""}];
                                    that.dialogshow(that.barcodeholder, false);
                                }
                            }
                            else{
                                //为false，说明上面已经处理过重复提示，这里不需要再管重复，只处理其他错误信息，且需要在报错提示内，删除重复信息
                                if (that.rcv_invalidmsgbox == "1") {
                                    //去掉重复的提示
                                    that.rcv_msgList = [];
                                    for (var i = 0; i < res.msgList.length; i++) {
                                        var a = res.msgList[i].Item1;
                                        if( a.indexOf("重复签收的条码") <= -1)
                                        {
                                            that.rcv_msgList.push(res.msgList[i]);
                                        }
                                    }
                                    that.dialogshow(this.barcodeholder, false);
                                }
                            }
                        }

                        //处理分拣提示，只有重复的时候，需要刷新分拣提示，其他包含错误的，都清空
                        if(res.errorResult == "only_repeat"){
                            if(this.isEasyMode == '1'){
                                this.easyData = res.master;
                            }
                            if (this.rcv_showinvalid == "1") {
                                //列表中显示无效签收的数据
                                if (this.isshowsignfloatwindow == "1") {
                                    //判断是否勾选显示签收提示浮窗
                                    if (!this.dialogfloatwindowVisible) {
                                        this.dialogfloatwindowVisible = true;
                                    }
                                    this.SampledDate = res.master.sampled_dt;
                                    if (res.reqgroup != null) {
                                        this.sorting_tips = res.reqgroup.sorting_tips;
                                        this.description = res.reqgroup.description;
                                        this.emerflag = res.master.emer_flag == "1" ? '(急)' : '';
                                        this.floatwindowcolor = this.changecolor(res.reqgroup.tuberack_color);
                                        if(this.description == "不可签收") {
                                            this.$alert("当前标本不可签收，请注意！");
                                        }
                                    }
                                }
                            }
                        }
                        else{
                            if (this.rcv_showinvalid == "1") {
                                //列表中显示无效签收的数据
                                if (this.isshowsignfloatwindow == "1") {
                                    //判断是否勾选显示签收提示浮窗
                                    if (!this.dialogfloatwindowVisible) {
                                        this.dialogfloatwindowVisible = true;
                                    }
                                    this.ClearFloatWindows();//先清空分拣提示
                                    this.description = "不可签收";
                                    this.$alert("当前标本不可签收，请注意！");
                                }
                            }
                        }

                        //3列表中显示无效签收的数据
                        that.rcv_showinvalidList();
                        that.txtbarcodeListcopy = that.returnmsg(res.msgList, 2);
                        that.txtbarcodeList = that.returnmsg(res.msgList, 2);
                        that.normalRcvFlag = "N"; //正常签收，N非正常签收,无论显示不显示都不打印(勾选正常签收时打印)
                    }
                    break;
                case 0:
                    if(this.isEasyMode == '1'){
                        this.easyData = res.master;
                    }
                    cmsg = rmaster.barcode + " 提示" + that.returnmsg(res.msgList, 2).join(",");
                    if(that.rcvusetts == '1') {
                        that.speakMessage(that.returnmsg(res.msgList, 2).join(","));
                    }
                    if (t_issync) {
                        that.txtbarcodeList = [cmsg];
                        that.rcv_msgList = res.msgList;
                        that.rcv_msg = res.rcvmsg;
                        that.rcv_flag = 2;
                        that.dialogshow(rmaster.barcode, true);
                        that.normalRcvFlag = "Y";
                    } else {
                        //提示(有弹窗)->是与否->走入dialogok
                        that.barcodeholder = cmsg;
                        that.rcv_msgList = res.msgList;
                        that.rcv_msg = res.rcvmsg;
                        that.rcv_flag = 0;
                        that.lastmaster = rmaster;
                        that.lastdetail = res.details.filter((item) => item.parent_itemcode == "" || item.parent_itemcode == item.req_itemcode);
                        that.txtbarcodeListcopy = that.returnmsg(res.msgList);
                        that.txtbarcodeList = that.returnmsg(res.msgList, 2);
                        that.dialogshow(that.txtbarcode, false);
                        that.normalRcvFlag = "Y";
                    }
                    break;
                case -99:
                    cmsg = barcodestr + " 出错!" + res.errmsg;
                    if(that.rcvusetts == '1') {
                        that.speakMessage(res.errmsg);
                    }
                    if (t_issync) {
                        that.txtbarcodeList = [cmsg];
                    } else {
                        //出错->直接显示信息
                        that.barcodeholder = cmsg;
                        let temp1 = [];
                        temp1.push(that.barcodeholder);
                        that.txtbarcodeListcopy = that.returnmsg(temp1, 1);
                        that.txtbarcodeList = that.returnmsg(res.msgList, 2);
                        that.normalRcvFlag = "N";
                    }
                    break;
                case 98: //98/99标识包条码返回
                    cmsg = barcodestr + " 出错!" + res.list[0];
                    if(that.rcvusetts == '1') {
                        that.speakMessage(res.list[0]);
                    }
                    if (t_issync) {
                        that.txtbarcodeList = [cmsg];
                    } else {
                        that.barcodeholder = cmsg;
                        that.txtbarcodeListcopy = that.barcodeholder;
                        that.normalRcvFlag = "N";
                    }
                    break;
            }
        },
        //消息声音提示
        speakMessage(message) {
            //语音播报
            console.log(" speekstr :", message);
            if (typeof jsObj != "undefined") {
                jsObj.Speek(message);
            } else {
                var u = new SpeechSynthesisUtterance();
                u.text = message;
                u.lang = "zh";
                u.rate = 0.7;
                speechSynthesis.speak(u);
            }
        },
        //弹出弹窗
        dialogshow(barcode, is_async) {
            let that = this;

            this.rcv_async = is_async;
            this.rcv_barcode = barcode;
            this.dialog_rcvpoptips = true;
            this.focusBarcode();
            setTimeout(() => {
                let btnel = null;
                switch (that.rcv_flag) {
                    case 0:
                        btnel = that.$refs.btnfocus1; //0,1
                        break;
                    case -1:
                        btnel = that.$refs.btnfocus2; //2
                        break;
                    case 1:
                        btnel = that.$refs.btnfocus3; //3,4
                        break;
                    case 2:
                        btnel = that.$refs.btnfocus5; //5,6,7
                        break;
                }
                if (btnel) btnel.$el.focus();
            }, 100);
        }, //行选中
        dialogok() {
            let that = this;
            //提示时点击是走入签收条码
            if (that.rcv_flag == 0 || that.rcv_flag == 2) {
                //0退回的标本，-1重复签收
                that.$tool
                    .request({
                        url: "LIS/LIS2/LIS212",
                        method: "post",
                        data: {
                            action: "rcvbarcode",
                            barcode: that.rcv_barcode,
                            rcvmsg: that.rcv_msg,
                            senduser: that.userinfoval,
                        },
                    })
                    .then((res) => {
                        console.log("res2", res);
                        that.txtbarcodeListcopy = "";

                        if (that.rcv_async) {
                            switch (res.flag) {
                                case 1:
                                    //条码签收成功
                                    let processeditem = -1;
                                    let t_barcode = that.rcv_barcode;
                                    if (res.master && res.master.barcode) {
                                        t_barcode = res.master.barcode;
                                    }
                                    if(this.isEasyMode == '1'){
                                        this.easyData.recieve_dt = res.master.recieve_dt;
                                        this.easyData.req_statname = res.master.req_statname;
                                    }
                                    processeditem = that.MasterData.findIndex((e) => e.barcode == t_barcode);
                                    if (processeditem >= 0) {
                                        that.MasterData[processeditem] = res.master;
                                        that.MasterData[processeditem].sflag = 0;
                                        that.MasterData = that.MasterData.slice(0);
                                        that.countError(that);
                                        // let temp = [];
                                        // temp.push(t_barcode);
                                        // that.txtbarcodeListcopy = that.returnmsg(temp, 1);
                                        // that.normalRcvFlag = "Y";
                                    }
                                    break;
                                case -1:
                                    //条码签收失败
                                    that.barcodeholder = that.rcv_barcode + " 失败" + res.msg;
                                    let temp1 = [];
                                    temp1.push(that.rcv_barcode);
                                    that.txtbarcodeListcopy = that.returnmsg(temp1);
                                    if (that.rcv_invalidmsgbox == "1") {
                                        //签收异常总是弹出提示框
                                        that.dialogshow(that.rcv_barcode, false);
                                    }
                                    //列表中显示无效签收的数据
                                    that.rcv_showinvalidList();
                                    that.normalRcvFlag = "N";
                                    break;
                            }
                        } else {
                            switch (res.flag) {
                                case 1:
                                    //条码签收成功
                                    that.barcodeholder = that.lastmaster.barcode + " 成功   " + res.msg;
                                    that.MasterData.splice(0, 0, res.master);
                                    that.detail = that.lastdetail;
                                    that.PatientInfo.barcode = that.rcv_barcode;
                                    if(this.isEasyMode != '1'){
                                        that.$refs.reqitemdialog.DealApplyData({ Data: that.detail, Cols: [] });
                                    }
                                    if(this.isEasyMode == '1'){
                                        this.easyData.recieve_dt = res.master.recieve_dt;
                                        this.easyData.req_statname = res.master.req_statname;
                                    }
                                    let temp = [];
                                    temp.push(that.barcodeholder);
                                    that.txtbarcodeListcopy = that.returnmsg(temp, 1);
                                    that.normalRcvFlag = "Y";
                                    break;
                                case -1:
                                    //条码签收失败
                                    that.barcodeholder = that.txtbarcode + " 失败  " + res.msg;
                                    let temp1 = [];
                                    temp1.push(that.barcodeholder);
                                    that.txtbarcodeListcopy = that.returnmsg(temp1,1);
                                    if (that.rcv_invalidmsgbox == "1") {
                                        //签收异常总是弹出提示框
                                        that.dialogshow(that.txtbarcode, false);
                                    }
                                    //列表中显示无效签收的数据
                                    that.rcv_showinvalidList();
                                    that.normalRcvFlag = "N";
                                    break;
                            }
                        }
                        that.closedialogShowMsg();
                        that.dialog_rcvpoptips = false;
                    })
                    .catch((e) => {
                        console.log("error", e);
                    });
            } else if (that.rcv_flag == 1) {
                this.dialog_rcvpoptips = false;

                let processeditem = that.MasterData.find((e) => e.barcode == that.rcv_barcode);
                if (processeditem) {
                    processeditem.sflag = 2;
                }
                that.MasterData = that.MasterData.slice(0);
            }
        },
        dialogcancel(canceltype) {
            let that = this;
            this.dialog_rcvpoptips = false;
            if (this.rcv_flag == 0 || this.rcv_flag == 1 || (this.rcv_flag == 2 && canceltype == 2)) {
                this.rcv_showinvalidList();
            } else if (this.rcv_flag == 2 && canceltype == 1) {
                let processeditem = that.MasterData.find((e) => e.barcode == that.rcv_barcode);
                if (processeditem) {
                    processeditem.sflag = 2;
                }
                that.MasterData = that.MasterData.slice(0);
            }
            this.closedialogShowMsg();
        },
        //关闭时弹出的消息
        closedialogShowMsg() {
            this.txtbarcodeList = this.txtbarcodeListcopy;
            this.focusBarcode();
        },
        //签收提示，切换默认选中的按钮
        chkbtnfun(obj) {
            if (obj) {
                setTimeout(() => {
                    obj.$el.focus();
                }, 100);
            }
        },
        //主表根据sflag显示不同颜色
        xTableDiv_rowClass({ seq, row, rowIndex, $rowIndex }) {
            if (row.sflag) {
                switch (row.sflag) {
                    case 1:
                        return "processingcls";
                    case -1:
                        return "errocls";
                    case 2:
                        return "erroalreadyread";
                }
            }
        },
        //异步时，统计错误条数显示到右上的消息框
        countError(that) {
            let errocount = that.MasterData.filter((te) => te.sflag == -1).length;
            if (errocount > 0) that.txtbarcodeList = ["目前有 " + errocount + " 条错误未处理"];
        },
        //主表单元格样式，根据req_groupna显示背景色
        xTableDiv_cellCustomStyle(param) {
            let { row, rowIndex, column, columnIndex } = param;
            if (column.property === "req_groupna") {
                //  console.log("param", param);
                return "background-color:" + this.$pub.ColorChange(row.tube_color) + ";color:" + this.$pub.colorConvert(row.tube_color) + ";";
            }
        },
        //从列表中删除该记录
        RemoveFromMasterData(that, barcode) {
            //从列表中删除该记录
            let req_groupid = null;
            let processeditem = that.MasterData.findIndex((e) => e.barcode == barcode);
            if (processeditem >= 0) {
                req_groupid = that.MasterData[processeditem].req_groupid;
                that.MasterData.splice(processeditem, 1);
                that.countError(that);
            }
            console.log("rm", barcode);
            processeditem = that.barcoderec.findIndex((e) => e == barcode);
            if (processeditem >= 0) {
                that.barcoderec.splice(processeditem, 1);
                that.remove_reqgroupnaInfo(req_groupid, that);
            }
        },
        //以下打印相关

        //标签打印弹出dialog
        btnLabelPrint() {
            let data = this.MasterData;
            if (data.length == 0) {
                this.dialog_labprintdialog = false;
            } else {
                this.dialog_labprintdialog = true;
            }
        },
        //扫描条码时是否打印
        IsSelectPrint(barcode) {
            switch (this.radioPrintWays) {
                case "1":
                    //不打印
                    break;
                case "2":
                    //总是打印
                    this.PrintSelectWays(barcode);
                    break;
                case "3":
                    //正常签收打印
                    if (this.normalRcvFlag == "Y") {
                        //只有normalRcvFlag="Y"的打印
                        this.PrintSelectWays(barcode);
                    }
                    break;
            }
        },
        PrintSelectWays(barcode) {
            let sql = "";
            let that = this;
            that.$tool
                .request({ url: "ucent/print", method: "post", data: { action: "testprint" } })
                .then((printinfo) => {
                    switch (that.chkprint) {
                        case "1":
                            //打印标签
                            if (barcode == "") barcode = that.lastmaster.barcode;
                            that.$pub.printbarcode(that, barcode, "1", printinfo.barstyle, printinfo.barcodepname, "1");
                            break;
                        case "2":
                            //打印检验申请单（此处要做修改）
                            if (barcode == "") barcode = that.lastmaster.barcode;
                            sql = "select 1 as 条数,* from req_master_all_name where 条码号 in ('" + barcode + "')";
                            that.$pub.printlistbill(that, sql, "1", that.ReqRptstyle, "检验申请单样式", "");
                            break;
                        case "3":
                            //都打印
                            if (barcode == "") barcode = that.lastmaster.barcode;
                            sql = "select 1 as 条数,* from req_master_all_name where 条码号 in ('" + barcode + "')";
                            that.$pub.printbarcode(that, barcode, "1", printinfo.barstyle, printinfo.barcodepname, "1");
                            that.$pub.printlistbill(that, sql, "1", that.ReqRptstyle, "检验申请单样式", "");
                            break;
                    }
                })
                .catch((e) => {
                    console.log("error", e);
                });
        },
        //检验申请单打印
        PrintReqList(e) {
            if (!this.ReqRptstyle) {
                this.$alert("请检查是否设置了检验申请单样式！");
                return false;
            }
            if (e.shiftKey) {
                //调整在选项
                let sql = "select top 1 * from req_master_all_name";
                this.$pub.printlistbill(this, sql, "3", this.ReqRptstyle, "检验申请单样式", "");
            } else {
                //打印
                let data = this.$refs.xTablePop.getSelectRecords();
                if (data.length > 0) {
                    let barcode = "";
                    let cnt = data.length;
                    data.forEach((item) => {
                        if (barcode == "") {
                            barcode = item.barcode;
                        } else {
                            barcode = barcode + "','" + item.barcode;
                        }
                    });
                    let sql = "select * from req_master_all_name where 条码号 in ('" + barcode + "')";
                    this.$pub.printlistbill(this, sql, "1", this.ReqRptstyle, "检验申请单样式", "");
                } else {
                    this.$alert("请选择要打印的申请单！");
                }
            }
        },
        //标签打印
        PrintLab(e) {
            if (e.shiftKey) {
                //调整
                this.$alert("请在申请、采血本地选项页面条码编码规则中调整门诊条码格式！");
            } else {
                //打印
                let barcode = "";
                let data = this.$refs.xTablePop.getSelectRecords();
                if (data.length > 0) {
                    data.forEach((item) => {
                        barcode += item.barcode + ",";
                    });
                    barcode = barcode.substring(0, barcode.length - 1);
                } else {
                    this.$message.warning("请选择要打印的标签！");
                    return false;
                }
                let that = this;
                this.$tool.request({ url: "ucent/print", method: "post", data: { action: "testprint" } }).then((printinfo) => {
                    let k = Number(this.labnum);
                    for (let i = 0; i < k; i++) {
                        that.$pub.printbarcode(that, barcode, "1", printinfo.barstyle, printinfo.barcodepname, "1");
                    }
                });
            }
        },
        //清单打印
        btnPrint(e) {
            if (!this.ReqRcvstyle) {
                this.$alert("请在申请、采血本地选项页面条码编码规则中选择签收清单格式！");
                return false;
            }
            let tcolunm = this.$col.MasterColumn;
            let str = JSON.stringify(tcolunm);
            //let str = JSON.stringify(this.$col.MasterColumn);
            str += "\r";
            let data = [];
            if(this.isEasyMode == '1'){
                data = this.MasterDataDisplay;
            }
            else {
                data = this.$refs.xTable1.afterFullData;
            }
            let no = 1;
            data.forEach((item) => {
                item.cnt = data.length;
                item.seq = no;
                no++;
            });
            // data.push({ cnt: data.length });
            //console.log(data);
            str += JSON.stringify(data);
            jsObj.Log("签收清单打印：" + str);
            let sql = btoa(encodeURIComponent(str));
            if (e.shiftKey) {
                //调整
                // let sql = "select top 1 1 as 条数,* from req_master_all_name";
                // this.$pub.printlistbill(this, sql, "3", this.ReqRcvstyle, "签收清单样式", "");

                jsObj.SetCustomJsonPrintConfig(this.ReqRcvstyle, sql, this.userno, "签收清单样式");
            } else {
                //打印
                // let data = this.$refs.xTable1.tableData;
                // let barcode = "";
                // let cnt = data.length;
                // data.forEach((item) => {
                //     if (barcode == "") {
                //         barcode = item.barcode;
                //     } else {
                //         barcode = barcode + "','" + item.barcode;
                //     }
                // });
                // let sql = "select '" + cnt + "' as 条数,* from req_master_all_name where 条码号 in ('" + barcode + "')";
                // this.$pub.printlistbill(this, sql, "1", this.ReqRcvstyle, "签收清单样式", "");
                //jsObj.SetCustomJsonPrintConfig(this.ReqRcvstyle, sql, this.userno, "签收清单样式");
                jsObj.PrintCustomJsonReport(this.ReqRcvstyle, sql, this.userno, "签收清单样式", "");
                this.$confirm("打印完成，是否清除已签收列表?", "提示", {
                    confirmButtonText: "确定",
                    cancelButtonText: "取消",
                    type: "warning",
                })
                    .then(() => {
                        this.MasterData = [];
                        this.barcoderec = [];
                        this.detail = [];
                        if(this.isEasyMode != '1'){
                            this.$refs.reqitemdialog.DealApplyData({ Data: that.detail, Cols: [] });
                        }
                        this.lastmaster = [];
                        this.lastdetail = [];
                    })
                    .catch(() => {});
            }
        },
        //以上打印相关
        userinfoblur(val) {
            this.userinfoval = val;
            this.$refs.barcode.focus();
        },
        userinfochange(code, name) {
            this.userinfoval = code;
            if(this.sendusercheckout != "2"){
                this.$refs.barcode.focus();
            }
        },
        //选中条码框
        HightlightPos(myField) {
            if (!myField) myField = document.getElementById("barcodediv");
            myField.selectionStart = 0;
            myField.selectionEnd = myField.value.length;
        },
        focusBarcode(myField) {
            if (!myField) myField = document.getElementById("barcodediv");
            myField.focus();
        },
        getoption() {
            //从服务器获取配置
            this.$tool
                .request({
                    url: "LIS/LIS2/LIS212",
                    method: "post",
                    data: {
                        action: "getoptions",
                    },
                })
                .then((res) => {
                    this.recieveuser = res.recieveuser;
                    this.performdept = res.performdept;
                    this.allowrecievetype = res.allowrecievetype;
                    this.rcv_invalidmsgbox = res.rcv_invalidmsgbox;
                    this.rcv_dupnomsgbox = res.rcv_dupnomsgbox;
                    this.rcv_showinvalid = res.rcv_showinvalid;
                    this.ReqRptstyle = res.ReqRptstyle; //检验申请单样式
                    this.ReqRcvstyle = res.ReqRcvstyle; //送达清单样式
                    this.RejectiReasonOption = res.RejectiReasonOption;
                    this.Options = res;
                    this.sendusercheckout = res.sendusercheckout;
                    if(this.isEasyMode != '1'){
                        this.$refs.reqitemdialog.DealApplyData({ Data: [], Cols: res.vxtab.Cols });
                    }
                    this.payinback_flag = res.modifyreqitemonlycharge;
                    this.islogin = res.islogin; // 是否需要输入工号密码
                    this.isshow = res.isShow; // 是否显示待签收列表
                    this.isquerymode = res.isquerymode; // 查询模式
                    this.showreqgroupdetailcnt = res.showreqgroupdetailcnt; // 签收后显示各分单类别标本个数（不勾仅显示总数）
                    this.isshowsignfloatwindow = res.isshowsignfloatwindow; // 显示签收提示浮窗
                    //不需要加本地设置了，记住上次的选择即可
                    // if(!!res.rcvdefaultprtmode){
                    //     this.radioPrintWays = res.rcvdefaultprtmode; // 标本签收默认打印模式
                    // }
                    this.rcvusetts = res.rcvusetts; // 启用语音提醒
                    this.rcvtts_normal = res.rcvtts_normal; // 正常签收播报文字
                    this.rcvtts_emer = res.rcvtts_emer; // 急诊标本播报文字

                    this.rcvshowsumdetails = res.rcvshowsumdetails; // 是否隐藏分单类别数量统计
                    // alert(this.ReqRptstyle);
                })
                .catch((e) => {
                    console.log("error", e);
                });
        },
        //显示详细内容的列表
        updatedetail(res, that) {
            setTimeout(() => {
                if (res.master.barcode == that.runningbarcode && this.isEasyMode != '1') {
                    that.detail = res.details.filter((item) => !item.parent_itemcode || item.parent_itemcode == "" || item.parent_itemcode == item.req_itemcode);
                    that.PatientInfo.barcode = res.master.barcode;
                    that.$refs.reqitemdialog.DealApplyData({ Data: that.detail, Cols: [] });
                    that.$refs.xTable1.setCurrentRow(res.master);
                } else {
                    //console.log("cancel", res.master.barcode , that.runningbarcode);
                }
            }, 800);
        },
        //增加到左下的群组统计
        reqgroupnaInfo(resmaster, that) {
            if (this.showreqgroupdetailcnt != "1") {
                that.barcoderec.push(resmaster.barcode);
                that.updateSumInfoCount(that);
            } else {
                let dataindex = that.barcoderec.findIndex((item) => item == resmaster.barcode); //当前列表中没有这条数据则加一
                if (dataindex < 0) {
                    that.barcoderec.push(resmaster.barcode);
                    //当前主列表没有就加入统计
                    let pindex = that.SumInfo.findIndex((eitem) => eitem.reqgroupid === resmaster.req_groupid);
                    if (pindex >= 0) {
                        that.SumInfo[pindex].content.sum++;
                        that.SumInfo = that.SumInfo.slice(0);
                    } else {
                        let reqgroupid = resmaster.req_groupid;
                        let tempjson = { req_groupna: resmaster.req_groupna, sum: 1, tubecolor: resmaster.tube_color };
                        if(this.rcvshowsumdetails == '1'){
                            //隐藏左下角统计项，只显示总计
                        }
                        else {
                            that.SumInfo.push({ reqgroupid: reqgroupid, content: tempjson });
                        }
                    }
                }

                that.updateSumInfoCount(that);
            }
        },

        removerromdetailcnt(master, that) {
            let processeditem = that.barcoderec.findIndex((e) => e == master.barcode);
            if (processeditem >= 0) {
                that.barcoderec.splice(processeditem, 1);
            }
            this.remove_reqgroupnaInfo(master.req_groupid, that);
        },

        //删除后更新左下的群组统计
        remove_reqgroupnaInfo(req_groupid, that) {
            // console.log("rm", req_groupid);
            if (this.showreqgroupdetailcnt != "1") {
                that.SumInfo.splice(-99, 1);
            } else {
                let pindex = that.SumInfo.findIndex((eitem) => eitem.reqgroupid === req_groupid);
                if (pindex >= 0) {
                    let rnum = that.SumInfo[pindex].content.sum - 1;
                    if (rnum <= 0) {
                        that.SumInfo.splice(pindex, 1);
                    } else {
                        that.SumInfo[pindex].content.sum = rnum;
                        that.SumInfo = that.SumInfo.slice(0);
                    }
                }
            }
            that.updateSumInfoCount(that);
        },
        updateSumInfoCount(that) {
            // console.log('sum',that.SumInfo);
            let sumitem = that.SumInfo.find((item) => item.reqgroupid == -99);
            if (sumitem) {
                sumitem.content.sum = that.barcoderec.length;
            } else {
                let inittempjson = { req_groupna: "总", sum: that.barcoderec.length, tubecolor: 0 };
                that.SumInfo.splice(0, 0, { reqgroupid: -99, content: inittempjson });
            }
        },
        //包条码中获取条码信息
        getbarcodeinfo(barcode, that) {
            that.$tool
                .request({
                    url: "LIS/LIS2/LIS212",
                    method: "post",
                    data: {
                        action: "getbarcodeinfo",
                        barcode: barcode,
                    },
                })
                .then((res) => {
                    if(res.Item3){
                        that.packagedata.push(res.Item3);
                    }
                });
        },
        appendDialog(data, packagebarcode) {
            this.specimenData = data;
            this.packagebarcode = packagebarcode;
            this.specimenkey++;
            this.dialogSpecimenRcv = true;
        },
        //统一设置返回消息放入数组
        returnmsg(msgs, way) {
            var msg = [];
            if (way == 1) {
                if (msgs.length > 0) {
                    msgs.forEach((item) => {
                        msg.push(item);
                    });
                }
            } else {
                if (msgs.length > 0) {
                    msgs.forEach((item) => {
                        msg.push(item.Item1);
                    });
                }
            }
            return msg;
        },
        rcv_showinvalidList() {
            let that = this;
            if (this.rcv_async) {
                that.RemoveFromMasterData(that, that.rcv_barcode);
            } else {
                if (this.rcv_showinvalid == "1") {
                    //列表中显示无效签收的数据
                    if (this.lastmaster && this.lastdetail) {
                        let data = this.MasterData.findIndex((item) => item.barcode == this.lastmaster.barcode);
                        if (data < 0) {
                            this.MasterData.splice(0, 0, this.lastmaster);
                            if(this.isEasyMode != '1'){
                                this.$refs.xTable1.setCurrentRow(this.lastmaster);
                            }
                        } else {
                            if(this.isEasyMode != '1'){
                                this.$refs.xTable1.setCurrentRow(data[0]);
                            }
                        }
                        if (this.lastdetail.length > 0) {
                            this.detail = this.lastdetail;
                            this.PatientInfo.barcode = data.barcode;
                            if(this.isEasyMode != '1'){
                                this.$refs.reqitemdialog.DealApplyData({ Data: this.detail, Cols: [] });
                            }
                        }
                    }
                    this.focusBarcode();
                } else {
                    //无效签收的数据列表不显示
                    this.focusBarcode();
                }
            }
        }, //关闭弹窗
        detailretrieve({ row }) {
            let that = this;
            // console.log("detailretrieve");
            that.PatientInfo.txtbarcode = row.barcode;
            that.DisplayMsg(that, row.barcode, row, row.res);
            that.Exedetailretrieve(that, row);
            that.focusBarcode();
        },
        Exedetailretrieve(that, row, details) {
            // console.log("row", row);
            var barcode = row.barcode;
            if (that.detail && that.detail.length > 0 && that.detail[0].barcode == barcode) {
                // console.log("detail no change");
            } else {
                if (details) {
                    // console.log("inputdetail");
                    that.detail = details.filter((item) => !item.parent_itemcode || item.parent_itemcode == "" || item.parent_itemcode == item.req_itemcode);
                    that.PatientInfo.barcode = barcode;
                    that.$refs.reqitemdialog.DealApplyData({ Data: that.detail, Cols: [] });
                } else {
                    that.$tool
                        .request({
                            url: "LIS/LIS2/LIS212",
                            method: "post",
                            data: {
                                action: "getdetails",
                                barcode: barcode,
                            },
                        })
                        .then((res) => {
                            // console.log("details", res);
                            that.detail = res.details.filter((item) => !item.parent_itemcode || item.parent_itemcode == "" || item.parent_itemcode == item.req_itemcode);
                            that.PatientInfo.barcode = barcode;
                            that.$refs.reqitemdialog.DealApplyData({ Data: that.detail, Cols: [] });
                        })
                        .catch((e) => {
                            console.log("error", e);
                        });
                }
            }
        },
        loginUser() {
            //护工需要先登录程序
            this.$rm_Login({
                type: "用户登录验证",
                btn: {
                    confirmBtnText: "确定",
                    cancelBtnText: "取消",
                },
            })
                .then((res) => {
                    if (res.flag == "1") {
                        this.userinfoval = res.userid;
                        this.readonly = true;
                    } else {
                        //登录失败
                        this.userinfoval = "";
                        this.userinfoname = "";
                        this.readonly = true;
                    }
                })
                .catch((e) => {
                    this.txtbarcode = "请先双击登录程序后再操作";
                    this.readonly = true;
                });
        },
        //护士签收
        btnSign() {
            let tabledata = [];
            if(this.isEasyMode == '1'){
                tabledata = this.MasterDataDisplay;
            }
            else {
                tabledata = this.$refs.xTable1.tableData;
            }
            let barcode = "";
            tabledata.forEach((item) => {
                if (barcode.indexOf(item.barcode) < 0) {
                    barcode += item.barcode + ",";
                }
            });
            barcode = barcode.substring(0, barcode.length - 1);
            //护工需要先登录程序
            this.$rm_Login({
                type: "用户登录验证",
                btn: {
                    confirmBtnText: "确定",
                    cancelBtnText: "取消",
                },
            })
                .then((res) => {
                    if (res.flag == "1") {
                        this.userinfoval = res.userid;
                        this.$tool
                            .request({
                                url: "LIS/LIS2/LIS212",
                                method: "post",
                                data: {
                                    action: "signsenduser",
                                    barcodes: barcode,
                                    senduser1: this.userinfoval,
                                },
                            })
                            .then((response) => {
                                if (response.flag == "1") {
                                    this.$message({
                                        message: response.msg,
                                        type: "success",
                                    });
                                } else {
                                    this.$message({
                                        message: response.msg,
                                        type: "error",
                                    });
                                }
                            });
                    } else {
                        //登录失败
                        this.userinfoval = "";
                        this.userinfoname = "";
                        this.readonly = true;
                    }
                })
                .catch((e) => {
                    this.txtbarcode = "请先双击登录程序后再操作";
                    this.readonly = true;
                });
        },
        //清除
        btnClear() {
            this.$confirm("是否清除签收列表（清除后将无法再打印和护工签字）？", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            })
                .then(() => {
                    this.txtbarcode = "";
                    this.txtbarcodeList = "";
                    this.txtbarcodecopy = "";
                    this.MasterData = [];
                    this.barcoderec = [];
                    this.lastmaster = [];
                    this.detail = [];
                    this.PatientInfo.barcode = "";
                    if(this.isEasyMode != '1'){
                        this.$refs.reqitemdialog.DealApplyData({ Data: [], Cols: [] });
                    }
                    this.lastdetail = [];
                    this.chkprint = "1";
                    // this.radioPrintWays = 1;
                    // this.userinfoval = "";
                    this.SumInfo = [];
                    this.ClearFloatWindows();//清空分拣提示
                    if(this.isEasyMode == '1'){
                        this.easyData = [];
                    }
                })
                .catch(() => {
                    //console.log("moment",new Date().getTime());
                });
        },
        packageChange() {},
        specimenChange() {},
        packageCancel(object) {
            this.packagedata = [];
            this.dialogPackageRcv = false;
            if (object.length > 0) {
                if (this.rcv_showinvalid == "1") {
                    //列表中显示无效签收的数据
                } else {
                    object = object.filter((item) => item.rcvflag == "1"); //过滤出有效签收的数据
                }

                for (const master of object) {
                    //  console.log("calmaster", master);
                    let data = this.MasterData.findIndex((item) => item.barcode == master.barcode);
                    if (data < 0) {
                        this.reqgroupnaInfo(master, this); //统计分单类别信息
                        this.MasterData.push(master);
                    }
                }
            }
            this.barcodeholder = "请扫描条码号";
        },
        CancelTips() {
            this.dialogVisible = false;
            this.description = null;
            this.reject_reason = null;
        },
        // 标本退回 弹窗确定按钮
        CommitTips() {
            if (this.reject_reason == "") {
                this.$message.error("请选择退回原因！");
                return;
            }

            if (this.islogin) {
                if (this.loginuserno == "") {
                    this.$message.error("请填写工号！");
                    return;
                }
                this.checklogin();
            } else {
                this.rejectbarcodes();
            }
        },

        rejectbarcodes() {
            this.$tool
                .request({
                    url: "LIS/LIS2/LIS213",
                    method: "post",
                    data: {
                        action: "scanbarcode",
                        barcode: this.RejetTempRow.barcode,
                    },
                })
                .then((res) => {
                    if (res.flag == 1) {
                        this.RejetTempRow.rejectmsg = res.rejectmsg;
                        this.Commit();
                    } else if (res.flag == -99) {
                        // this.$message.error("已生成报告，请去标本回退页面处理！");
                        this.$alert("已生成报告，请去标本回退页面处理！", "提示");
                        this.dialogVisible = false;
                        this.description = null;
                        this.reject_reason = null;
                        this.loginuserno = "";
                        this.loginpwd = null;
                        return;
                    } else {
                        this.$message.error("标本不可回退！");
                        this.dialogVisible = false;
                        this.description = null;
                        this.reject_reason = null;
                        this.loginuserno = null;
                        this.loginpwd = null;
                        return;
                    }
                })
                .catch((e) => {
                    console.log("error", e);
                    this.dialogVisible = false;
                    this.description = null;
                    this.reject_reason = null;
                    this.loginuserno = null;
                    this.loginpwd = null;
                });
        },

        checklogin() {
            this.$tool
                .request({
                    url: "LIS/LIS2/LIS213",
                    method: "post",
                    data: {
                        action: "logincheck",
                        userno: this.loginuserno,
                        password: md5("rms-" + this.loginpwd + "-rme"),
                    },
                })
                .then((res) => {
                    if (res.flag == 0) {
                        this.$message.error(res.msg);
                        this.loginuserno = "";
                        this.loginpwd = "";
                    } else {
                        this.rejectbarcodes();
                    }
                })
                .catch((e) => {
                    console.log("error", e);
                    this.loginuserno = null;
                    this.loginpwd = null;
                });
        },

        // 执行退回操作
        Commit() {
            let rejectinfo = [];
            let temp = [];
            temp.push(this.RejetTempRow.barcode);
            temp.push(this.reject_reason);
            temp.push("0");
            temp.push(this.description);
            temp.push(this.tellman);
            temp.push(this.RejetTempRow.rejectmsg);
            temp.push(this.loginuserno);
            temp.push("");
            rejectinfo.push(temp);
            this.$tool
                .request({
                    url: "LIS/LIS2/LIS213",
                    method: "post",
                    data: {
                        action: "rejectbarcodes",
                        rejectinfo: rejectinfo,
                    },
                })
                .then((res) => {
                    if (res.faildBarcode.length == 0) {
                        this.RejetTempRow.req_statname = "退回";
                        this.RejetTempRow.req_stat = 8;
                        this.txtbarcodeList = [this.RejetTempRow.barcode + " 退回成功"];
                        this.$message.success("退回成功！");
                        if(this.isEasyMode == '1'){
                            this.easyData = [];
                        }
                        this.ClearFloatWindows();//清空分拣提示
                    } else {
                        this.$message.error(res.faildBarcode[0].Item2);
                    }
                    this.dialogVisible = false;
                    this.description = null;
                    this.reject_reason = null;
                })
                .catch((e) => {
                    this.$message.error(e);
                    this.dialogVisible = false;
                    this.description = null;
                    this.reject_reason = null;
                    this.loginuserno = null;
                    this.loginpwd = null;
                    console.log("error", e);
                });
        },
        specimenCancel(object) {
            this.specimenData = [];
            this.dialogSpecimenRcv = false;
            this.dialogPackageRcv = false;
            if (object.length > 0) {
                for (const master of object) {
                    //  console.log("calmaster", master);
                    let data = this.MasterData.findIndex((item) => item.barcode == master.barcode);
                    if (data < 0) {
                        this.reqgroupnaInfo(master, this); //统计分单类别信息
                        this.MasterData.push(master);
                    }
                }
            }
            this.barcodeholder = "请扫描条码号";
        },
        ReqChangeSubmit() {
            var row = this.$refs.xTable1.getCurrentRow();
            this.Exedetailretrieve(this, row);
        },
        // 查询当日采样未签收的数据
        Gettodayreqdata(querymode, querystr) {
            this.$tool
                .request({
                    url: "LIS/LIS2/LIS212",
                    method: "post",
                    data: {
                        action: "gettodayreqdata",
                        querymode: querymode,
                        querystr: querystr,
                    },
                })
                .then((res) => {
                    this.mainreqdata = res.data;
                    this.maintotal = this.mainreqdata.length;
                })
                .catch((e) => {
                    console.log("error", e);
                });
        },

        // 从当日采样数据中删除
        RemoveFromMainreqdata(barcode) {
            let item = this.mainreqdata.findIndex((e) => e.barcode == barcode);
            if (item >= 0) {
                this.mainreqdata.splice(item, 1);
                this.maintotal--;
            } else {
                //
            }
        },

        diagUserInfoChange(code, name, row) {
            this.currentRow.tellman = row.hidname;
            // this.dialogusersel = false;
        },
    },
};
</script>

<style scoped>
.pagetop {
    /* width: 100%;
    height: 80px;
    display: -webkit-box;
    -webkit-box-pack: left;
    -webkit-box-align: center;
    position: absolute;
    z-index: 99;
    border: 1px solid #ccc; */
    width: 100%;
    left: 0;
    right: 0;
    display: -webkit-box;
    -webkit-box-pack: center;
    -webkit-box-align: center;
    border: solid 1px #ccc;
    position: absolute;
    z-index: 99;
    height: 80px;
    overflow-x: auto;
    overflow-x: overlay;
}

.pagecenter {
    position: absolute;
    top: 85px;
    width: 100%;
    left: 0;
    bottom: 0px;
    overflow: auto;
}

.middle-center {
    position: absolute;
    height: 100%;
    left: 0px;
    right: 455px;
    overflow: auto;
}

.middle-right {
    position: absolute;
    height: 100%;
    width: 450px;
    right: 0px;
}
.table1style tr td {
    padding: 1px 1px 1px 5px;
}
::-webkit-scrollbar {
    width: 0px;
    height: 5px;
    border: 4px solid white;
}
::-webkit-scrollbar-thumb {
    background-color: #c1c1c1;
}
::-webkit-scrollbar-track {
    background-color: #f1f1f1;
}
/* Buttons */
::-webkit-scrollbar-button:single-button {
    background-color: #bbbbbb;
    display: block;
    border-style: solid;
    height: 5px;
    width: 5px;
}
/* Left */
::-webkit-scrollbar-button:horizontal:decrement {
    margin-right: 2px;
    border-width: 4px 4px 4px 0;
    border-color: #f1f1f1 transparent #f1f1f1 #f1f1f1;
    background-color: #000000;
}
::-webkit-scrollbar-button:horizontal:decrement:hover {
    border-color: #d2d2d2 transparent #d2d2d2 #d2d2d2;
}
/* Right */
::-webkit-scrollbar-button:horizontal:increment {
    margin-left: 2px;
    border-width: 4px 0 4px 4px;
    border-color: #f1f1f1 #f1f1f1 #f1f1f1 transparent;
    background-color: #000000;
}
::-webkit-scrollbar-button:horizontal:increment:hover {
    border-color: #d2d2d2 #d2d2d2 #d2d2d2 transparent;
}
/* .table1style .el-input--medium {
    font-size: 18px;
    font-weight: 700;
} */
::v-deep .popdialogstyle tr td div .el-input__inner {
    border: 1px solid rgba(255, 254, 254, 0) !important;
    background-color: rgba(255, 254, 254, 0) !important;
}
::v-deep .el-message-box {
    width: 670px;
}
.mytableclass table tr td {
    padding: 3px;
}
.top-deal {
    right: 5px;
    position: absolute;
    top: 50px;
    display: flex;
    align-items: center;
}
::v-deep .processingcls td {
    color: #1087ba;
}
::v-deep .errocls td {
    color: red;
}
::v-deep .erroalreadyread td {
    color: #0a5fb4;
}
::v-deep tr.vxe-body--row.row--current {
    color: #000000;
    font-weight: bold;
}
.el-switch,
.el-checkbox {
    float: right;
}
.el-checkbox .el-checkbox__label {
    font-size: 14px !important;
}
#barcodediv::-webkit-input-placeholder {
    color: #0000ff;
}
.fixbottom{
    position: absolute;
    left: 0px;
    bottom: 0%;
    z-index: 1;
    overflow: hidden;
    width: 100%;
}
</style>
